1.3.0 • Published 8 years ago
chialab-ajax v1.3.0
Ajax
A XMLHttpRequest wrapper.
Install
$ npm i chialab-ajax --save
$ bower i chialab-ajax --save
Example
// GET request
var xhrGet = Ajax.get('http://my.api.url/')
.then(function(res) {
console.log('Result:', res);
}, function(xhr) {
console.error('Error:', xhr.response);
});
// POST request
var xhrPost = Ajax.post('http://my.api.url/', { title: 'Hello.' })
.then(function(res) {
console.log('Result:', res);
}, function(xhr) {
console.error('Error:', xhr.response);
});