# simple-ajax

> Simple ajax module

Latest version **2.6.0** (published 2016-07-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install simple-ajax
pnpm add simple-ajax
yarn add simple-ajax
bun add simple-ajax
```

## 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 | 2.6.0 |
| Published | 2016-07-19 |
| First published | 2014-03-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | Maurice Butler |
| Maintainers | mauricebutler |
| Keywords | ajax, xhr, simple |

## Links

- npm: https://www.npmjs.com/package/simple-ajax
- Repository: https://github.com/MauriceButler/simple-ajax
- Issues: https://github.com/MauriceButler/simple-ajax/issues
- npm.io page: https://npm.io/package/simple-ajax

## Dependencies (1)

- [query-string](https://npm.io/package/query-string.md) ^1.0.0

## Recent versions

- 2.6.0 (latest) — 2016-07-19
- 2.5.1 — 2016-06-14
- 2.5.0 — 2016-03-24
- 2.4.0 — 2016-03-04
- 2.3.2 — 2016-02-21
- 2.3.1 — 2015-10-27
- 2.3.0 — 2015-10-27
- 2.2.1 — 2015-10-21
- 2.2.0 — 2015-09-23
- 2.1.0 — 2015-04-02
- 2.0.0 — 2015-03-26
- 1.0.1 — 2015-01-06
- 1.0.0 — 2014-09-24
- 0.0.1 — 2014-03-18

## README

# simple-ajax

Simple ajax module.


## Usage

``` javascript
var Ajax = require('simple-ajax'),
    ajax = new Ajax('https://api.github.com/users/octocat/orgs');

ajax.on('success', function(event) {
    console.log('success', event);
});

ajax.send();
```

#### Or Provide Options Object

``` javascript
var ajax = new Ajax(
        {
            url: 'https://api.github.com/users/octocat/orgs',
            method: 'GET',
            headers: {
                myCustomHeader: 'my custom header value'
            }
        }
    );
```

### Available Options

``` javascript
{
    url: 'url to request',
    method: 'method to request with',
    cors: 'is CORS request (only needed for IE)',
    cache: 'set to false to explicitly break cache',
    data: 'JSON data to be sent with request',
    dataType: 'type of expected response',
    contentType: 'if JSON will try to parse response data',
    requestedWith: 'defaults to XMLHttpRequest',
    auth: 'used to set the Authorization header',
    headers: 'custom headers object'
}
```

### Add Event Listeners

``` javascript
ajax.on('success', function(event) {
    console.log('success', event);
});

ajax.on('error', function(event) {
    console.log('error', event);
});

ajax.on('complete', function(event) {
    console.log('complete', event);
});
```

### Send Request

``` javascript
ajax.send();
```

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