Copy codeThe Code is as follows: // set the default settings for Ajax operations
$. AjaxSetup ({
Cache: false,
Error: function (XMLHttpRequest, textStatus, errorThrown ){
If (typeof (errorThrown )! = "Undefined ")
$. Messager. alert (g_MsgBoxTitle, "An error occurred while calling the server. <Br/> "+ errorThrown, 'error ');
Else {
Var error = "<B style = 'color: # f00'>" + XMLHttpRequest. status + "" + XMLHttpRequest. statusText + "</B> ";
Var start = XMLHttpRequest. responseText. indexOf ("<title> ");
Var end = XMLHttpRequest. responseText. indexOf ("</title> ");
If (start> 0 & end> start)
Error + = "<br/>" + XMLHttpRequest. responseText. substring (start + 7, end );
$. Messager. alert (g_MsgBoxTitle, "An error occurred while calling the server. <Br/> "+ error, 'error ');
}
}
});
In this way, you can not write the error processing function in the ajax method.