Skip to content

Latest commit

 

History

History
68 lines (60 loc) · 1.1 KB

README.md

File metadata and controls

68 lines (60 loc) · 1.1 KB

errand

small javascript library

Usage

AJAX

Get json

x_x.errand({
    url: 'json-url',
    json: true
}).success(function(result) {
    console.log(result);
});

Post data

x_x.errand({
    url: 'post-url',
    method: 'post',
    data: {
        somedata: 'somevalue'
    }
}).success(function(result) {
    console.log(result);
}).error(function(message) {
    console.log(message);
});

Custom headers

somedata = {postdata: 'postvalue'}
x_x.errand({
    url: 'post-url',
    method: 'post',
    data: somedata,
    headers : {
        someheader: 'some header value'
    }
}).success(function(result) {
    console.log(result);
});

Abort/cancel request

var req = x_x.errand('http://abc.com');
req.cancel()

Extend object

x_x.extends({}, {someProperty: 'someValue'});

Type checks

someVar = {};
x_x.isVarTypeOf(someVar, Object); //true
x_x.isVarTypeOf(someVar, Array); //false

Attach events

x_x(window).on('ready', function(){ console.log('doc ready') });