Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (47.6k points)

Using jQuery, how can I cancel/abort an Ajax request that I have not yet received the response from?

1 Answer

0 votes
by (106k points)

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()

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...