Since XMLHttpRequest ,or the equivalent, object is returned by jQuery, so you can simply use abort function. To cancel ajax requests you have to follow below code.
var myRequest= $.ajax({
type: "POST",
url: "file.php",
data: "name=you&class=10",
success: function(e){
alert( "Awesome : " + e);
}
});
//Cancel the request
myRequest.abort();
That’s it 🙂