# tcb-missile

> A tiny AJAX library.

Latest version **0.1.1** (published 2015-01-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install tcb-missile
pnpm add tcb-missile
yarn add tcb-missile
bun add tcb-missile
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2015-01-05 |
| First published | 2014-12-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | The Code Bureau |
| Maintainers | sup3rman |

## Links

- npm: https://www.npmjs.com/package/tcb-missile
- Repository: https://github.com/thecodebureau/missile
- Issues: https://github.com/thecodebureau/missile/issues
- npm.io page: https://npm.io/package/tcb-missile

## Recent versions

- 0.1.1 (latest) — 2015-01-05
- 0.1.0 — 2014-12-02

## README

(AJAX) Missile
=======

Tiny AJAX library that aims to be VERY similar to jQuery's `$.ajax(settings)` method.

## Installation

```
npm install git://github.com/thecodebureau/missile.git
```

## Usage

Works exactly like jQuery's `$.ajax(settingsObject)` function.

```javascript
Missile({
  method: 'POST',
  url: '/api/objects',
  // one can also use dataType, like jQuery
  responseType: 'json',
  contentType: 'application/json',
  data: JSON.stringify({ key: 'value' }),
  success: function(response, textStatus, xhr) {
    console.log('success');
  },
  error: function(xhr, textStatus, errorThrown) {
    console.log('error');
  }
});
```

## Set Defaults

To set defaults for any option to be used anytime it is not supplied (supports
both Missile property names, or jQuery property names. See below.):

```javascript
Missile.setDefaults({
  contentType: 'application/json;charset=UTF-8'
});
```

## Compatability With & Differences to jQuery

Besides returning native XHR objects instead of jqXHR objects and dropping pre
IE8 support, Missile aims to be 100% compatible with jQuery's `$.ajax()`
function.

### Renamed Options 

TCB thinks some setting OPTIONS Are not named aptly considering property names
of native XHR objects. Thus, the following have been renamed. To retain afore mentioned
jQuery compatibility all jQuery property's are also still valid.

- accepts -> accept
- dataType -> responseType
- type -> method

## Implemented functionality

| property  | implemented | differences to jQuery       |
|-----------|-------------|----------------------------|
| `accepts`   | Yes         | Also available as `accept`.|
| `async` | No | N/A |
| `beforeSend` | No | N/A |
| `cache` | No | N/A |
| `complete` | Yes | None |
| `contents` | No | N/A |
| `contentType` | Yes | None |
| `context` | No | N/A |
| `converters` | No | N/A |
| `crossDomain` | No | N/A |
| `data` | Yes | Only accept a string (must be set according to `contentType`) or an object if `contentType` is 'application/json'. |
| `dataFilter` | No | N/A |
| `dataType` | Yes | Also available as `responseType`. Only accepts responseTypes accepted by the native XHR object. Which is 'arraybuffer', 'blob, 'document', 'json' and 'text'. |
| `error` | Yes | Returns a native XHR object instead of a jqXHR object. And it returns whatever you asked for with `responseType`/`dataType`. IE, if you asked for JSON you will get an error OBJECT back, not a status text or anything crazy like that. |
| `global` | No | N/A |
| `headers` | Yes | Not sure of jQuery's default behaviour, but Missile overrites any properties that might have been set with accept[s] or similar. |
| `ifModified` | No | N/A |
| `isLocal` | No | N/A |
| `jsonp` | No | N/A |
| `jsonpCallback` | No | N/A |
| `mimeType` | No | N/A |
| `password` | No | N/A |
| `processData` | Yes | The processing can currently only create JSON string, not URL encoded. |
| `scriptCharset` | No | N/A |
| `statusCode` | No | N/A |
| `success` | Yes | It is passed a native XHR object instead of a jqXHR object. |
| `timeout` | No | N/A |
| `traditional` | No | N/A |
| `type` | Yes | Also available as `method`. |
| `url` | Yes | None |
| `username` | No | N/A |
| `xhr` | Yes | In the default mode, it does not create ActiveXObject objects, only XMLHttpRequest objects |
| `xhrFields` | No | N/A |

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