A mini Ajax library provides Ajax, jsonp and ready features for simple web applications.
β | β | β | β | β | β |
There are only 3 interfaces in miniAjax, including Ajax, jsonp and ready functions:
ajax({
url: "./testXhr.php", //links to server
type: "POST", //request method
data: { name: "WeideMo", age: 26 }, //request params
dataType: "json", //received dataType
success: function (response, xml) {
// do something when success
},
fail: function (status) {
// do something when fail
}
});
jsonp({
url:"https://github.com/WeideMo/", //links to server
callback:"callback", //reception callback name negotiated with the backend-server
data:{id:"1000120"}, //request params
success:function(json){
// do something when success
},
fail:function(){
// do something when fail
},
time:10000 //custom timeout
})
ready(function(){
// do something when page ready
})
Almost support all of the browsers, even the original IE series.
The compressed version is less than 2K, if you use gzip, it will be less than 1K.
MiniAjax is just the basic requirement to meet web development.It's only responsible for three things: Ajax
, jsonp
and ready
.
You can get more principles and usage ->https://github.com/WeideMo/jsonp