XMLHttpRequest error 0 proper management (retry the request)
jquery, xmlhttprequest
Solution
Look here for what you're after: Defensive AJAX and AJAX retries in jQuery.
Basically in the error handler, you can do `$.ajax(this);`
$.ajax({
url : 'timeOutPage.html',
type : 'get',
timeout : 20000,
error : function(xhr, textStatus, errorThrown ) {
if (textStatus == 'timeout') {
$.ajax(this);
return;
}
}
});
The linked article has a more in-depth example with a retry limit, etc...as with most jQuery, you can almost copy/paste their example to get going.
Problem
When XMLHttpRequest gets error 0 it means there is no connection and most of the times you just want to retry in some time. Is there a simple way to transparently retry the XMLHttpRequest notifying the user the connection is lost (just like gmail does)? (I am using jQuery)