/*****************************************************************
jQuery Ajax Package (Universal)
*****************************************************************/
$ (function () {
/**
* Ajax Encapsulation
* URL to send the requested address
* Data sent to the server, array storage, such as: {"date": new Date (). GetTime (), "state": 1}
* Async Default value: True. By default, all requests are asynchronous requests. If you need to send a synchronization request, set this option to false.
* Note that the sync request will lock the browser, and the user's other actions must wait for the request to complete before it can be executed.
* Type Request method ("POST" or "get"), default to "get"
* DataType expected server to return the data type, commonly used such as: XML, HTML, JSON, text
* SUCCESSFN Successful callback function
* ERRORFN Failure callback function
*/
Jquery.ax=function (URL, data, async, type, DataType, SUCCESSFN, ERRORFN) {
Async = (Async==null | | async== "" | | typeof (ASYNC) = = "undefined")? "True": async;
Type = (Type==null | | type== "" | | typeof (type) = = "undefined")? "POST": type;
DataType = (Datatype==null | | datatype== "" | | typeof (DATATYPE) = = "undefined")? "JSON": dataType;
data = (Data==null | | data== "" | | typeof (DATA) = = "undefined")? {"Date": new Date (). GetTime ()}: data;
$.ajax ({
Type:type,
Async:async,
Data:data,
Url:url,
Datatype:datatype,
Success:function (d) {
SUCCESSFN (d);
},
Error:function (e) {
ERRORFN (e);
}
});
};
/**
* Ajax Encapsulation
* URL to send the requested address
* Data sent to the server, array storage, such as: {"date": new Date (). GetTime (), "state": 1}
* SUCCESSFN Successful callback function
*/
Jquery.axs=function (URL, data, SUCCESSFN) {
data = (Data==null | | data== "" | | typeof (DATA) = = "undefined")? {"Date": new Date (). GetTime ()}: data;
$.ajax ({
Type: "Post",
Data:data,
Url:url,
DataType: "JSON",
Success:function (d) {
SUCCESSFN (d);
}
});
};
/**
* Ajax Encapsulation
* URL to send the requested address
* Data sent to the server, array storage, such as: {"date": new Date (). GetTime (), "state": 1}
* DataType expected server to return the data type, commonly used such as: XML, HTML, JSON, text
* SUCCESSFN Successful callback function
* ERRORFN Failure callback function
*/
Jquery.axse=function (URL, data, SUCCESSFN, ERRORFN) {
data = (Data==null | | data== "" | | typeof (DATA) = = "undefined")? {"Date": new Date (). GetTime ()}: data;
$.ajax ({
Type: "Post",
Data:data,
Url:url,
DataType: "JSON",
Success:function (d) {
SUCCESSFN (d);
},
Error:function (e) {
ERRORFN (e);
}
});
};
});
JQuery Ajax Encapsulation Generic class