Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
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()

Browse Categories

...