• 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 and 500

 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm running into a situation where I need to be able to handle situations in ajax where the server stops responding. What I've done for testing is I've killed apache and then submitted an ajax request. From what I can tell, it would seem that I get all the way through readyState 2 and then it dies. I get no timeout or anything. FF throws an exception that I am catching and IE just tells me object expected when it hits my httpReq object.

I'm looking for elegent ways to handle this because I am not able to check the http status code for a 500. Any suggestions?
 
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 solution people implement is adding a timer to the request. You can set a peroid of time and if it fires then use the abort() method to kill the request. Then you can try the request again or tell the user to try back later.

Eric
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Eric Pascarello:
The solution people implement is adding a timer to the request. You can set a peroid of time and if it fires then use the abort() method to kill the request. Then you can try the request again or tell the user to try back later.

Eric



Ok, I understand what you are saying. But I am not a Javascript Jedi. Are you talking about using setTimeout() function or is it something else? And where in the process of the ajax call are you specifying this timeout.

Thanks.
 
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
When you do the send() you would set the window.setTimeout(blah,time);

When the request comes back you need to cancel it with cancelTimeout()


Eric
 
reply
    Bookmark Topic Watch Topic
  • New Topic