I have a search text box where, after pressing the key, AJAX is called to return the search results for the entered text. This results in an AJAX call for each keystroke.
For example, if I type airport:
I get 7 ajax requests, each of which is looking for a, ai, air, airp, airpo, airpor, airport, respectively - however, the problem is that they can all start one after another, but do not necessarily end in the same order most often I I get the results in the wrong order, i.e. I could write airportand get the result for airportjust to get the result for airpolater.
How do I handle this in jQuery here?
Update:
The timer delay is 3 seconds, but the problem is that when executing one AJAX request, another request, when it is made, cancels the previous request, etc.
How can I do this in code?
source
share