Testcase for jQuery Ticket 7461
Adapting AJAX retries in jQuery from http://zeroedandnoughted.com/defensive-ajax-and-ajax-retries-in-jquery for jQuery >= 1.4.3
by jitter
JavaScript
$.ajax({
url: "http://www.google.com",
tryCount: 0,
retryLimit: 3,
error: function(xhr, textStatus, errorThrown) {
this.tryCount++;
if (this.tryCount <= this.retryLimit) {
console.log("Retry #"+this.tryCount);
//this fixes the recursion errors
this.context = undefined;
$.ajax(this);
return;
}
console.log('We have tried ' + this.retryLimit + ' times and it is still not working. We give in. Sorry.');
return;
}
});