NOTE: I neither use nor maintain this project anymore.
This is a simple jquery 'plugin' to help with retrying ajax requests. It's not a real plugin because it
doesn't use the plugin architecture; rather, it uses a single call to
ajaxPrefilter
to modify the way ajax requests work. This does
not provide delays between attempts (backoff); there are other plugins that provide that kind of
functionality.
Include the jquery-ajax-retry.js
script on your page. (The JS is generated from the coffeescript).
$.ajax({
method: "get",
url: "/some/path",
dataType: "json",
success: function(data, textStatus, jqXHR) { ... }
error: function(jqXHR, textStatus, httpError) { ... }
// retry options
timeout: 3000, // [required] You must provide a timeout to use retries
maxTries: 3 // [required] How many times to retry.
retryCodes: [404, 500] // [optional] HTTP error codes on which to retry.
})
Might work with any 1.5+ version of jQuery. Tested with 1.7.2.
Taken from the technique here:
http://www.moretechtips.net/2012/04/retrying-ajax-requests-with-jquery.html