哔哔one
(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){//错误方法增强处理if (layer) {layer.msg("出错了,请联系管理员!", 2, 3, null, true);} else {alert("出错了,请联系管理员!");}fn.error(XMLHttpRequest, textStatus, errorThrown);},success:function(data, textStatus){//成功回调方法增强处理var error = data.error;if (error != undefined && error == true) {if (layer) {layer.msg(data.reason, 2, 3, null, true);} else {alert(data.reason);}return;}fn.success(data, textStatus);}});_ajax(_opt);};})(jQuery);