how to stop ajax call in jquery code example
Example 1: jquery cancel ajax request on click
var xhr = $.ajax({
type: "POST",
url: "some.php",
data: "name=John&location=Boston",
success: function(msg){
alert( "Data Saved: " + msg );
}
});
//kill the request
xhr.abort()
Example 2: jquery abort ajax
var xhr = $.ajax({
type: "GET",
url: "https://www.codegrepper.com/myapi.php",
success: function(response){
//do something
}
});
xhr.abort(); //kill the request