• 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

xmlHttp.onreadystatechange only fires once

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I'm an Ajax newbie and I could really use some help on a little problem I'm having.

When I run the code below in either IE6 or FF 1.5 I get into the stateChanged function once when the state is 0, but then the state never seems to change and the page never updates. I've verified that I can call the ajaxrelated.asp page directly and it returns the proper HTML fragment.

I've wrapped the code in different try/catch blocks and they are never executed...

Any help you can offer would be greatly appreciated.

 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
xmlHttp.onreadystatechange=stateChanged(spanName)
xmlHttp.open("GET",url,true)

wrong order, flip them

Also you can not do this:
stateChanged(spanName)

you are executing the function not assiging it.
You need to find a different way of passing the spanName.
It would help if you used OOP, but since you are using a global variable to hold the requeest object, put the spanName in a global variable also.

Eric
[ December 15, 2006: Message edited by: Eric Pascarello ]
 
Guy Hill
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Eric,

Thank you so much for the quick reply. I surely have a lot to learn about but making a few small adjustments based on your feedback got me over this hurdle!

Regards,
KS
 
Guy Hill
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Alright, I got too excited too quickly.

Now the readystate goes to 1, but it does not appear to be progress past that point. If I put an alert in the stateChange function the Ajax works properly, seemingly because the amount of time it takes me to click OK is enough time for the async call to the ajaxrelated.asp page to complete. But if I don't put an alert in that function the methods never fresh the content on my HTML page.

reply
    Bookmark Topic Watch Topic
  • New Topic