• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ajax question

 
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I use ajax from html page to call a jsp file which retrieve data from DB, and then get the result from generated xml file.

If its the first time to execute this block of code, it works good. But when I call it again (without refleshing the page), it runs through the code very quickly, and I can see the jsp is not really being called from the console. I got the value of row instantly, which seems like its a cached value. This problem happens in IE, but not in Firefox.

Does anyone experience this and know how to solve it? Thanks.


 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would usually submit my Ajax request to either a servlet or an action on the server. I am not familiar with submitting to a jsp. Is it possible that the client is caching the jsp for some reason? Try to expire the content on the JSP, by setting the caching headers. I am curious if this will resolve the issue.

Good luck, and keep us posted.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use POST, GET gets cached since GET requests are supposed to. You can also read this: http://radio.javaranch.com/pascarello/2005/10/21/1129908221072.html

Eric
 
reubin haz
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, guys.
Thank you Eric, I read your blog and use appending a Math.random() to the end of the url. Then it works. By the way, if I just change from get to post, it still won't solve the problem.

I'm just wondering if in case, I intend to cache the content, and want to retrieve data from the server side only after data is changed on the server side, then should I just leave my original code, or what else should I modify?

Thanks.
[ September 14, 2006: Message edited by: reubin haz ]
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The client does not know if data changed on the server and theere is no real way to push data to the client so you probably are stuck doing the way you are.

Eric
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To avoid cache in IE, use the following before submiting the request

 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic