Your question is quite vague in terms of the actual issue that you seem to be facing. But what I derive from it is that you are firing too many requests as you suggest rapid key presses!
As you would know, Ajax
is like a normal page request, just done async, so it is bound by the same network latency, throughput and round trip constraints.
A clean way to achieve the functionality you need is to use a technique called throttling. One of the best js
plugin for this purpose is located here: http://benalman.com/projects/jquery-throttle-debounce-plugin/
It basically allows you to rate-limit your requests to the server, thus not choking the resources and providing a smooth UI.
Also, unless you wish to trap certain special keys like <kbd>ESC</kbd>, I would suggest using keypress
or keydown
events. Can't remember the specific reasoning for it, but just a suggestion.