0.0.2 • Published 9 years ago

s-ajax v0.0.2

Weekly downloads
4
License
ISC
Repository
github
Last release
9 years ago

s-ajax

Work in Progress

NPM version Dependencies build status NPM license

A simple wrapper around the XMLHttpRequest API with support for Promises.

Installation

npm install --save s-ajax

s-ajax uses CommonJS, so bundle via Browserify/Webpack/etc. before use.

Usage

With callbacks
var ajax = require('s-ajax');

ajax.get('https://example.com', function(data) {
	console.log(data);
});

ajax.post('https://example.com', {foo: 'bar'}, function(response) {
	console.log(response);
});
With promises
var ajax = require('s-ajax/promise');

ajax.get('https://example.com').then(function(data) {
	console.log(data);
});

ajax.post('https://example.com', {foo: 'bar'}).then(function(response) {
	console.log(response);
});

In progress:

  • Tests & coverage
  • AJAX file upload support

License

Copyright (c) 2015, Sebastian Sandqvist s.github@sparque.me

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.