Back
Using jQuery, how can I cancel/abort an Ajax request that I have not yet received the response from?
If you want to abort Ajax requests using jQuery then you can just use abort().
See the code below:-
var xhr = $.ajax({ type: "POST", url: "some.php", data: "name=John&location=Boston",success: function(msg){ alert( "Data Saved: " + msg ); } }); xhr.abort()
var xhr = $.ajax({
type: "POST",
url: "some.php",
data: "name=John&location=Boston",
success: function(msg){
alert( "Data Saved: " + msg );
}
});
xhr.abort()
31k questions
32.8k answers
501 comments
693 users