【发布时间】:2011-12-24 11:40:13
【问题描述】:
一位团队成员将其放入我们的项目中
$(function() {
$("body").bind("ajaxError", function(event, XMLHttpRequest, ajaxOptions, thrownError){
alert(thrownError);
});
}
但是我想抑制我的一个错误(因为它会是噪音并且不需要验证)
function blah() {
...
errFunc = function(event, xhr, opts, errThrown) {
//what could I do here?
//event.stopImmediatePropagation()?
}
$.ajax({
url : '/unimportant_background_refresh',
type : 'GET',
data : { },
dataType : 'json',
success : updateBackgroundStuff,
error : errFunc, // Suppresses error message.
});
}
请问如何阻止 catch all 错误的发生?我可以在错误函数中做一些事情,比如{ event.StopPropogation(); },还是我必须制定一些机制让所有捕获都选择性地忽略事情?
【问题讨论】:
标签: javascript jquery error-handling