ajaxme
v1.0.0
Published
Lightweight Ajax helper
Downloads
12
Readme
ajaxme
Lightweight Ajax Helper
Minified version: 1kb
Gziped version: ~740bytes
Implementation :
UMD ready. It can be loaded via AMD, CommonJs and as global namespace.
AMD
define(['ajaxme'], function(AjaxMe){
var ajaxme = AjaxMe;
});
CommonJS
var ajaxme = require('ajaxme');
Global namespace
var ajaxme = window.AjaxMe;
API
get :
ajaxme.get({
url: 'data.json',
success: function(XMLHttpRequest) {
console.log('success', XMLHttpRequest);
},
error: function(XMLHttpRequest) {
console.log('error', XMLHttpRequest);
},
abort: function(XMLHttpRequest) {
console.log('abort', XMLHttpRequest);
},
loadstart: function(XMLHttpRequest) {
console.log('loadstart', XMLHttpRequest);
},
progress: function(XMLHttpRequest) {
console.log('progress', XMLHttpRequest.percent);
}
});
post :
ajaxme.post({
url: '/post',
data: 'name=Guest&age=26',
success: function(XMLHttpRequest) {
console.log('success', XMLHttpRequest);
},
error: function(XMLHttpRequest) {
console.log('error', XMLHttpRequest);
},
abort: function(XMLHttpRequest) {
console.log('abort', XMLHttpRequest);
},
loadstart: function(XMLHttpRequest) {
console.log('loadstart', XMLHttpRequest);
},
progress: function(XMLHttpRequest) {
console.log('progress', XMLHttpRequest.percent);
}
});
post JSON :
ajaxme.post({
url: '/post',
json: true,
data: JSON.stringify({
name: 'Guest',
age: '26'
}),
success: function(XMLHttpRequest) {
console.log('success', XMLHttpRequest);
},
error: function(XMLHttpRequest) {
console.log('error', XMLHttpRequest);
},
abort: function(XMLHttpRequest) {
console.log('abort', XMLHttpRequest);
},
loadstart: function(XMLHttpRequest) {
console.log('loadstart', XMLHttpRequest);
},
progress: function(XMLHttpRequest) {
console.log('progress', XMLHttpRequest.percent);
}
});