Lightweight Ajax Helper
UMD ready. It can be loaded via AMD, CommonJs and as global namespace.
define(['ajaxme'], function(AjaxMe){
var ajaxme = AjaxMe;
});
var ajaxme = require('ajaxme');
var ajaxme = window.AjaxMe;
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);
}
});
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);
}
});
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);
}
});