I want to set up global behavior for all AJAX requests, and sometimes I need to interrupt queue like this
$.ajaxSetup({
success: function(data, textStatus, jqXHR) {
if ( data.error ) { jqXHR.reject(); }
}
});
// later
$.ajax({ some: option }).done( function(html) { do_something(html); } );
here I want to finish (do not call done with function(html)) when data.error is present
Is it possible ? Or maybe exists another way for it ?