Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

returning value from jQuery

 
Mukhi Vla
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Can any one help in how to get value back from jQuery function?

My purpose is to get a selected value from list box when Button is clicked.

When I click on the button I am invoking a function , in that function i am able to alert the selected valu. But I want that value on .jsp page to set the selected value to session.

My code in .jsp page




code from .js file



how to get the selected width back to jsp file?


 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by "back to the JSP file"?
 
Mukhi Vla
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to get the selected value on jsp page from the javascript function. To set that value to session.

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the time any JavaScript code runs on the client, the JSP that ran on the server is long gone.

You need to understand how JSP works to see why what you are asking makes no sense. Please read this article.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll need to call the server to set anything in session, either via Ajax or a form submission. As Bear says it'll be a good idea to understand the various life cycles involved in web apps before going too much further.
 
Mukhi Vla
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got it. I will have to try AJAX. In my jsp I don't have any form submission. There is a href link that is redirected to a controller class. But before going to the controller I should have this value set.

Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic