Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/renie/ajax
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/renie/ajax
- Owner: renie
- License: gpl-3.0
- Created: 2015-09-30T20:32:09.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-02-02T15:36:44.000Z (almost 8 years ago)
- Last Synced: 2024-11-11T09:47:53.630Z (about 2 months ago)
- Language: JavaScript
- Size: 40 KB
- Stars: 7
- Watchers: 3
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Code Climate](https://codeclimate.com/github/renie/Ajax/badges/gpa.svg)](https://codeclimate.com/github/renie/Ajax)
# Ajax
A tiny XMLHTTPRequest abstraction, 2kb minified and a bit less than 900b minified and gzip.
## Why?
I just want to use jQuery Ajax like methods, but without loading ALL jQuery.
## Why not use XYZ lib?
Because I made no reasearch before building this :bowtie:.
## Include in your project
You can just download it from this repo. But I'd recommend you to use bower method:
```
bower install Ajax
```You can also use npm:
```
npm install ajax-abstraction
```Yeap, not same name. It was already taken on NPM. Life is not so beautiful =/
## How to use
If you know how to use jQuery Ajax methods, you know how to use this. See below:
```javascript
Ajax.call({
url: '/foo',
success: function(data) {
// my success function
}
});
```This lib supports **UMD**. So, import this via **AMD**, **CommonJS** or importing min script in you HTML and using as **window global**.
It's possible to use **setup** method for setting default options. The same parameters can be passed.
## Options
* contentType [string]:
* The content type of your request;
* **default**: 'application/x-www-form-urlencoded; charset=UTF-8'.* context [object]:
* Context where your callbacks will be executed;
* **default**: window* data [string]:
* Data that will be passed on body of the request.* dataType [string]:
* Format that your data will be returned;
* **default**: JSON* fail [function]:
* Function that will be called if your function doesn't return code 200.* headers [json]:
* Headers of your request. This must be an Javascript Object.* method [string]:
* HTTP method used on this request;
* **default**: 'GET'.* success [function]:
* Function that will be called if your function returns code 200.## License
GPL 3 (full copy shipped with code)