I am trying to build an auto-complete UI. There is an input whose on keyup
function does an ajax call to server to fetch the most relevant data. But if user types a word which is, say 10 character long, so for each keyup
one ajax call is made and my dialogue box refreshes 10 times.
I have tried using abort()
for the ajax call. When I do an abort to previous ajax call, the call is not made but still it waits for 10 calls before executing the last one, which makes the user experience very bad.
So is there a way to execute just the current ajax call without any delay from the previous ones?
A part of my code:
var request_autocomplete=jQuery.ajax({});
$('.review_autocomplete').keyup(function() {
request_autocomplete.abort();
request_autocomplete=jQuery.ajax({
// DO something
});
});