Backbone.js ajaxRetry
Exponentially retry Backbone.ajax and $.ajax requests
Installation
npm install --save backbone-ajaxretry
In your client app main.js
, add the following line to default retry settings:
;
Or override any of the default settings using set
: passing keyword arguments
;
Usage
The default settings are:
base: 2718281828 y: 025 retryCount: 3 onlyBackbone: false
By default both Backbone.ajax
and $.ajax
Server Errors are retried. To only retry Backbone.ajax
requests and not also [regular] $.ajax
requests, change the onlyBackbone
default setting to true
.
For Backbone.js sync, fetch, save or destroy, pass exhaust
in the options object as a callback function to run when retries fail
- please note that
exhaust
supersedes theerror
callback - if
exhaust
method is not passed, retries will end without further action - the returned
jqXHR
object has been extended with the ajax request options,
thus allowingjqXHR.type
,jqXHR.url
, etcetera
// Backbone ex.myModel; // $.ajax ex.$;
- Changelog >>> releases
- Dependency: Underscore.js
- Implied: