function initAjax() {
jQuery.ajaxSetup({
timeout: 10000,
cache: false
});
$(document.body).ajaxComplete(function(event, request, ajaxOption, state){
if(!Comm.browser.isIE && state == "timeout"){
Comm.onceError("请求超时,请稍候重试!");
}
}).ajaxError(function(event, request, ajaxOption, thrownError){
var passError = /&passerror=|^passerror=/;
var hasJsonName = /&jsonName=|^jsonName=/;
var data = ajaxOption.data;
var isJsonRPC = data && hasJsonName.test(data) && (!passError.test(data));
try{
if(!Comm.browser.isIE && (!request || request.status == 0)){
Comm.onceError("网络连接中断,请检查你的网络连接");
return;
}
var state_code = request.status.toString().substr(0, 3);
if (state_code != "200") {
var msg = '';
msg = $HTTP_STATE_CODE[state_code];
if(msg) msg = msg[1] || msg[0];
if (!msg) msg = "请求数据失败,请稍后重试";
if (state_code == "401") Comm.error(msg, function() {
top.location.href = "http://www.a.com/login";
return;
});
if (isJsonRPC) Comm.error(msg);
}
}catch(e){
if(Comm.browser.isIE)Comm.onceError("请求超时,请稍候重试!");
}
})
}
jQuery.ajaxSetup({
timeout: 10000,
cache: false
});
$(document.body).ajaxComplete(function(event, request, ajaxOption, state){
if(!Comm.browser.isIE && state == "timeout"){
Comm.onceError("请求超时,请稍候重试!");
}
}).ajaxError(function(event, request, ajaxOption, thrownError){
var passError = /&passerror=|^passerror=/;
var hasJsonName = /&jsonName=|^jsonName=/;
var data = ajaxOption.data;
var isJsonRPC = data && hasJsonName.test(data) && (!passError.test(data));
try{
if(!Comm.browser.isIE && (!request || request.status == 0)){
Comm.onceError("网络连接中断,请检查你的网络连接");
return;
}
var state_code = request.status.toString().substr(0, 3);
if (state_code != "200") {
var msg = '';
msg = $HTTP_STATE_CODE[state_code];
if(msg) msg = msg[1] || msg[0];
if (!msg) msg = "请求数据失败,请稍后重试";
if (state_code == "401") Comm.error(msg, function() {
top.location.href = "http://www.a.com/login";
return;
});
if (isJsonRPC) Comm.error(msg);
}
}catch(e){
if(Comm.browser.isIE)Comm.onceError("请求超时,请稍候重试!");
}
})
}