# ajaxretry

> Exponentially retry $.ajax requests

Latest version **1.1.2** (published 2015-06-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install ajaxretry
pnpm add ajaxretry
yarn add ajaxretry
bun add ajaxretry
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2015-06-01 |
| First published | 2014-06-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Gabriel Dibble |
| Maintainers | gdibble |
| Keywords | ajax, retry |

## Links

- npm: https://www.npmjs.com/package/ajaxretry
- Repository: https://github.com/gdibble/ajaxretry
- Issues: https://github.com/gdibble/ajaxretry/issues
- npm.io page: https://npm.io/package/ajaxretry

## Dependencies (2)

- [extend-object](https://npm.io/package/extend-object.md) ^1.0.0
- [lodash.defaults](https://npm.io/package/lodash.defaults.md) ^3.1.1

## Recent versions

- 1.1.2 (latest) — 2015-06-01
- 1.1.1 — 2015-06-01
- 1.0.2 — 2014-08-02
- 1.0.1 — 2014-06-16
- 1.0.0 — 2014-06-16

## README

# ajaxRetry

#### Exponentially retry $.ajax requests

&nbsp;

## Installation

```
npm install --save ajaxretry
```

&nbsp;<br>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 });
```

&nbsp;

## Usage
The default settings are:

```javascript
{
  base: 2.718281828,
  y: 0.25,
  retryCount: 3
}
```

&nbsp;

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, <br>thus allowing `jqXHR.type`, `jqXHR.url`, etcetera

```javascript
$.ajax({
  url: '/test',
  type: 'GET',
  exhaust : function (jqXHR, textStatus, errorThrown) {
    // Handle Internal Server Error
  }
});
```
&nbsp;

---

* **Changelog &gt;&gt;&gt;** [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)

&nbsp;

&nbsp;

*This module is a simplified version of [backbone-ajaxretry](https://github.com/gdibble/backbone-ajaxretry) by the same author.*

---
_Source: https://npm.io/package/ajaxretry · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
