cancel previous ajax request and sending another code example
Example: cancel previous ajax request
var currentRequest = null;
currentRequest = jQuery.ajax({
type: 'POST',
data: 'value=' + text,
url: 'AJAX_URL',
beforeSend : function() {
if(currentRequest != null) {
currentRequest.abort();
}
},
success: function(data) {
// Success
},
error:function(e){
// Error
}
});