ajax.tool.js
1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
var ajaxTool = {
/**
* ajax 请求
*
* @param options
* @param callback
*/
ajaxRequest : function(options, callback) {
var conf = {
type : "POST",
url : options.url,
dataType : "json",
async : false,
data : {},
success : function(rs) {
try {
if (callback) {
callback.apply(this, [ rs ]);
}
} finally {
}
},
error : function() {
}
};
$.extend(conf, options);
$.ajax(conf);
},
ajaxPost : function(url,frm, callback) {
$.post(url, $(frm).serialize(),callback);
},
sendAjax : function(URL, Parm, SuccFun, ErrorFun, PostTYPe, dataType, cacheType, asyncType) {
PostTYPe = (PostTYPe == null) ? "GET" : "POST";
cacheType = (cacheType == null) ? false : true;
dataType = (dataType == null) ? "json" : dataType;
ErrorFun = (ErrorFun == null) ? ajaxTool.ajaxError : ErrorFun;
asyncType = (asyncType == null) ? true : false;
$.ajax({
url : URL,
data : Parm,
cache : cacheType,
type : PostTYPe,
dataType : dataType,
success : SuccFun,
async : asyncType,
error : ErrorFun,
complete : function(XMLHttpRequest, textStatus) {
var s = XMLHttpRequest.status;
if (s == 202) {
// isp.relogin();
}
}
});
}
};