Lets look at my code:
$("#senderr").on("click", function(){
$.get("/echo/json").then(function(res){
//let's imagine something happen
throw "error";
});
});
$("#sendok").on("click", function(){
$.get("/echo/json").then(function(res){
$("#log").append("<li>send ok</li>");
});
});
$(document).on("ajaxStart", function(){
$("#log").append("<li>start</li>");
});
$(document).on("ajaxStop", function(){
$("#log").append("<li>stop</li>");
});
If you press "send ok", you can see that ajaxStart and ajaxStop events fired successfully. But if you just once press "send err" button which thrown runtime error in ajax callback, previous "send ok" behavior will never work again - ajaxStop event stop firing.
Why jQuery do it? What can i do to prevent this except using try-catch everywhere?