No more nonsense to say, directly to everyone paste code.
jquery (function ($) {
//Back up jquery Ajax method
var _ajax = $.ajax;
Rewrite the Ajax method to first determine that the login is executing the success function
$.ajax = function (opt) {
var _success = opt && opt.success | | function (A, b) {};
var _opt = $.extend (opt, {
success:function (data, textstatus) {
//If the request is redirected to the login page in the background, then data is stored in the source code of the login page, Here we need to find the evidence that data is the login page (tag)
if ((typeof data) = = ' String ' && data.indexof (' shangjiaajaxextend ')!=-1) {
window.location.href = ' http://' + window.location.host + '/s/busilogin/index ';
return;
} else {
_success (data, textstatus);
}
}
);
Return _ajax (_opt);
};
The overriding principle is that because the closure function is loaded first on the page, the $.ajax method can be directly overwritten here.
The point is that the red part of the content must be retrun otherwise in using the Load method load page times wrong "uncaught typeerror:cannot call methods ' done ' of undefined. ”