Most of the time, we all encounter the function of keyword search.
Our first idea, certainly, is to bind the response to the KeyUp event, and then will get the keyword to request an AJAX return response to the data processing
However, this time, if the KeyUp event is simply bound. So, every keystroke will send an AJAX request, which is obviously not what we want.
We hope to try to send Ajax requests after we have been free:
Therefore, we set the user to send this AJAX request after 1S without tapping the keyboard
Copy Code code as follows:
var timeout;
onkeyup = function () {
Cleartimeout (timeout);
Timeout = settimeout (function () {
Ajax request
}, 1000);
}
Of course, you can use another idea:
To block out Ajax requests:
Copy Code code as follows:
if (request) {
Request.abort ();
}
Request = $.ajax ()
But this Ajax request is best blocked before the Ajax issue