How to Abort Ajax requests using jQuery

by THavamani 2013-08-09 11:43:05

how can I cancel/abort an Ajax request ?

<i>Most of the jQuery Ajax methods return an XMLHttpRequest (or the equivalent) object, so you can just use abort().</i>

Example:
var xhr = $.ajax({
type: "POST",
url: "mani.php",
data: "name=John&location=Boston",
success: function(msg){
alert( "Data Saved: " + msg );
}
});

//kill the request
xhr.abort()
1404
like
0
dislike
0
mail
flag

You must LOGIN to add comments