aqax v0.0.2
aqax
Minimal, promise based XMLHttpRequest wrapper
var promise = aqax('http://foo.com').get();
promise.then(function(xhr) {
//success
});
promise.fail(function(xhr) {
//failure
});
###API
####Send
var promise = aqax(url).send(method, options);
####Shortcuts
var promise = aqax(url).get(options);
var promise = aqax(url).post(options);
var promise = aqax(url).put(options);
var promise = aqax(url).delete(options);
####Options
Name | Type | Description | Default
---- | ---- | ------------|---------|
headers | object | map of request headers |
query | string/object | query string, objects are serialized
data | string/object | data to send, objects are serialized based on the type
type | string | type provides hints for auto setting headers and serialzing data. Available values are form
, json
, xml
, html
, text
| none
cache | boolean | add timestamp to query string for cache busting if false | true
timeout | number | client request timeout | 0 |
encoding | string | specify an encoding that is appended to auto set Content-type request header | none
autoHeaders | boolean | If true, auto sets the Content-type and Accepts headers based upon the type
unless they have already been set | true
###Build
Build with browserify:
browserify ./src/aqax.js --standalone aqax > ./dist/aqax-with-q.js