我认为您无法使用jQuery进行控制。全局ajaxError在ajax调用期间发生的任何错误上被调用。但是,“局部”错误回调在全局回调之前被调用,因此您可以设置一个变量来告诉全局回调不运行。
例如:
var handledLocally = false;$('html').ajaxError(function(e, xhr, settings, exception) { if (!handledLocally){ //run the normal error callback pre and the reset handledLocally }});error: function(){ //set handledLocally to true to let the global callback it has been taken care of handledLocally = true;}- 您可以查看显示如何完成此操作的jsFiddle(一定要在单击链接之前单击顶部的run):http
- //jsfiddle.net/e7By8/



