jQuery(document).ready(function(){
var currentRequest = null;
jQuery('#searchbox').keyup(function() {
var text = jQuery(this).val();
currentRequest = jQuery.ajax({
type: 'POST',
data: 'search_text=' + text,
url: 'AJAX_URL',
beforeSend : function() {
if(currentRequest != null) {
currentRequest.abort();
}
},
success: function(data) {
jQuery('#data').html(data).show();
}
});
});});
Last active
August 29, 2015 13:56
-
-
Save amitmerchant1990/8915141 to your computer and use it in GitHub Desktop.
JavaScript snippet for aborting ajax rquest if previous call has not been completed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment