Stop $.ajax on beforeSend
ajax, jquery
Solution
$.ajax({
url : 'my_action',
dataType: 'script',
beforeSend : function(xhr, opts){
if(1 == 1) //just an example
{
xhr.abort();
}
},
complete: function(){
console.log('DONE');
}
});
Problem
I have this jQuery ajax call: ``` $.ajax({ url : 'my_action', dataType: 'script', beforeSend : function(){ if(1 == 1) //just an example { return false } }, complete: function(){ console.log('DONE'); } }); ``` I want to stop the ajax call under the `beforeSend` if the condition returns `true` but return false does not stop the ajax call. How can I `stop` the ajax call on the `beforeSend`? ======= UPDATE ========= `return false` works as well.