(function ($) {
//备份jquery的ajax方法
var _ajax = $.ajax;
//重写jquery的ajax方法
$.ajax = function (opt) {
//备份opt中error和success方法
var fn = {
error: function (XMLHttpRequest, textStatus, errorThrown) { },
success: function (data, textStatus) { }
}
if (opt.error) {
fn.error = opt.error;
}
if (opt.success) {
fn.success = opt.success;
}
//扩展增强处理
var _opt = $.extend(opt, {
error: function (XMLHttpRequest, textStatus, errorThrown) {
$.loadCookiesForAjax(opt, errorThrown, function () {
fn.error(XMLHttpRequest, textStatus, errorThrown);
});
},
success: function (data, textStatus) {
if (typeof (loadnumberForAjax) != "undefined" ) {
loadnumberForAjax = 0;
}
if (typeof (loadnumber) != "undefined" ) {
loadnumber = 0;
}
//成功回调方法增强处理
fn.success(data, textStatus);
}
});
_ajax(_opt);
};
})(jQuery);
JQuery重写ajax
最新推荐文章于 2021-08-06 13:00:41 发布