• 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

strange problem with plain ajax

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Folks,
Encountering a strange problem with ajax:
i have a simulation kind of program in which there is (among others) an ajax call that's made.
when i programmatically "restart" the simulation (by creating a new session), the next time that ajax call is made, the server request never seems to be made even though alert statements in the javascript indicate that it is. furthermore, in the readystate function, the readystate switches from 1 to 2 to 3 to 4, and the readystatus becomes 200 and no errors are being thrown, all of this, again, without the server being called.
any ideas what might be happening?
Thanks,
Nilesh
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How are you determining this. Alerts are a poor indicator.

Using Firebug in Firefox will let you see exactly what's being posted to the server.
 
Nilesh Thali
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bear, thanks for responding. I'm running this inside of my IDE debugger, and i have a breakpoint in the Action (struts), and though it hits the breakpoint the first time around, after "restarting" the simulation, it doesn't.
don't know if this is the issue, but during the restart call to the server, i invalidate the existing session, and then make a call to request.getSession(true) to create a new one.
i'll keep investigating. i know it's something stupid. just checking to see if anyone's made the same mistake before
 
Nilesh Thali
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
alright, i think i figured it out - thanks to wikipedia: http://en.wikipedia.org/wiki/XMLHttpRequest - (who btw want all of the instructional stuff on the page moved out)
IE (at least) is caching the response, because my URL is not changing. so it never makes that second call since it thinks the URL is the exact same.
there were many workarounds on the page for this - apparently the best way is to add the pragma "no-cache" but that didn't work for me. in fact it weirdly messed up my form element alignments.
so i had to choose the wasteful way of actually appending a "Math.random()" element to my parameter in the ajax call, so i could fool it into thinking it was a different url. apparently this fills up my cache with all these useless urls, but hey! it fixes my problem for now.
If anybody has any better suggestions, i'd appreciate it.
Thanks again,
Nilesh
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is why I recommended what I did. You would have seen that right away. IDEs are generally very poor tools for debugging client-side issues.
 
passwords must contain 14 characters, a number, punctuation, a small bird, a bit of cheese and a tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic