Skip to content
This repository has been archived by the owner on Sep 18, 2019. It is now read-only.

Latest commit

 

History

History
40 lines (28 loc) · 1.36 KB

README.md

File metadata and controls

40 lines (28 loc) · 1.36 KB

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.

Usage

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.
})

Compatibility

Might work with any 1.5+ version of jQuery. Tested with 1.7.2.

Credits

Taken from the technique here:

http://www.moretechtips.net/2012/04/retrying-ajax-requests-with-jquery.html

License

This work is under the MIT License