jQuery ajax error
attempt to hook into error handler
by mowglisanu
HTML
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
JavaScript
(function($) { $(function () {
$(document).ajaxSend( function (event, xhr, obj) {
console.log(xhr);
xhr.error = xhr.fail = function () {
alert("hook called");
};
xhr.abort();
});
$.ajax({ url: window.location.href, error: function () { alert("main called"); }});
}); }(jQuery));