私がやろうとしているのは、すべてのエラーをキャッチすることであり、私は自分自身を処理します。
しかし、jQuery.ajax()でエラーが発生すると、エラーオプションでエラーが発生したかどうかを知ることができます。しかし、それは私のwindow.onerrorイベントではキャッチできません。
window.onerror = function(e) {
console.log("i was here! ERROR: ", e);
console.log("-----------");
return true; //dont show errors on console
}
$(function() {
$.ajax({
url: "asdasdasd/as/da/sdtest/asdasd",
error: function() {
// ok i know here is an error and it catches on my window.onerror. BUT look at your console, still have a GET error. That error I want to handle. Can be with try/catch or inside the window.onerror. I want that Exception object. Not this one that I created.
throw new Error("it catches, but still have errors on my console");
}
});
test[0].test = "it fails";
});
ここでテストできます:http://jsfiddle.net/uHPXm/4/