https://github.com/gdibble/ajaxretry
ajaxRetry
https://github.com/gdibble/ajaxretry
Last synced: 29 days ago
JSON representation
ajaxRetry
- Host: GitHub
- URL: https://github.com/gdibble/ajaxretry
- Owner: gdibble
- License: mit
- Created: 2014-06-16T06:18:50.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2021-01-15T01:37:05.000Z (over 5 years ago)
- Last Synced: 2025-11-17T16:02:48.914Z (7 months ago)
- Language: JavaScript
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ajaxRetry
#### Exponentially retry $.ajax requests
## Installation
```
npm install --save ajaxretry
```
In your client app `main.js`, add the following line to default retry settings:
```javascript
require('ajaxretry');
```
Or override any of the default settings using `set`: passing keyword arguments
```javascript
require('ajaxretry').set({ y:0.3 });
```
## Usage
The default settings are:
```javascript
{
base: 2.718281828,
y: 0.25,
retryCount: 3
}
```
For `$.ajax` requets (also shorthand `$.get` and `.post`), pass `exhaust` in the options object as a callback function to run when retries fail
* please note that `exhaust` supersedes the `error` 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 allowing `jqXHR.type`, `jqXHR.url`, etcetera
```javascript
$.ajax({
url: '/test',
type: 'GET',
exhaust : function (jqXHR, textStatus, errorThrown) {
// Handle Internal Server Error
}
});
```
---
* **Changelog >>>** [releases](https://github.com/gdibble/ajaxretry/releases)
---
* **Dependency:** [Underscore.js](http://underscorejs.org/)
* ***Implied:***
* [jQuery](http://jquery.com), [zepto.js](http://zeptojs.com), [ENDER](http://ender.jit.su) **or** even your own `$` library *which defines `$.ajax`*
---
* [npmjs.org/package/ajaxretry](https://www.npmjs.org/package/ajaxretry)
*This module is a simplified version of [backbone-ajaxretry](https://github.com/gdibble/backbone-ajaxretry) by the same author.*