| Author |
Action class being called only once in ajax
|
Deeps Mistry
Ranch Hand
Joined: Jan 31, 2009
Posts: 189
|
|
Hi all,
I am new to AJAX. I am using struts1.1
I have a text box 'PerBox'. when i enter some value in the textbox, onchange event calls my ajaxfunction. I call my struts action class and in the action class i set the response which gets printed on the jsp.
My problem is that my action class is being called only once. why so?
here is my jsp page:
my action class:
The system out statement is getting printed only on first call. On consecutive calls it is not getting printed. Also, the response is being taken from cache, since even if i change the value in my action class it shows up the previous value.
Thanks.
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
Are you setting up the page on the server NOT to cache the page? You need to set the correct headers with the response.
GET requests are meant to be cached. It makes surfing the net a lot faster.
Eric
|
 |
Saifuddin Merchant
Ranch Hand
Joined: Feb 08, 2009
Posts: 576
|
|
You have four options out here,
1. Use an Ajax library that takes care of such problems - my Favorite Jquery.
2. As Eric suggested set up the page for no-cache - you'll need to look at the headers for this.
3. Use the age old trick of generating a random parameter and appending it as part of your get request.
4. Since your request is not idempotent anyways - why not make a POST request.
|
Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
|
 |
Deeps Mistry
Ranch Hand
Joined: Jan 31, 2009
Posts: 189
|
|
Sam Mercs wrote:You have four options out here,
1. Use an Ajax library that takes care of such problems - my Favorite Jquery.
2. As Eric suggested set up the page for no-cache - you'll need to look at the headers for this.
3. Use the age old trick of generating a random parameter and appending it as part of your get request.
4. Since your request is not idempotent anyways - why not make a POST request.
Hey thanks a lot Sam and Eric for your help.
|
 |
 |
|
|
subject: Action class being called only once in ajax
|
|
|