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

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

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -