jquery - ajax timeout callback function -


is there way run function if jquery's $.ajax function hits it's timeout?

i.e.

$.ajax({ ... ... ,timeout:1000(){do if timeout) ...  }); 

$.ajax({     ...     timeout: 1000,     error: function(jqxhr, textstatus, errorthrown) {         if(textstatus==="timeout") {            //do on timeout         }      } });​ 

for more information check out jquery documentation:

http://api.jquery.com/jquery.ajax/


edited

it's been on year since answered , textstatus possible values have changed "success", "notmodified", "error", "timeout", "abort",or"parsererror". error callbacks, last 4 statuses possible.

also can wire error handlers through returned jquery deferred promise object's .fail method:

var promise = $.ajax({ timeout: 1000 });  promise.fail(function(jqxhr, textstatus) {     if(textstatus==="timeout") {         // handle timeout       } }); 

Comments

Popular posts from this blog

php - cannot display multiple markers in google maps v3 from traceroute result -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -