This is how it works.
- Person starts typing into textbox.
- On onkeyPress event, I fire the query.
- I get the result and render it onto JSP.
Case 1: I have just typed 'a'. 'a','e','i' are such words that are found frequently in any string. So, it is obvious that I get more number of rows into result, but even before result gets rendered I type another character and it gets hanged, which is apparent.
My solution : Don't fire query on onKeyPress, but after hitting the Enter key.
How does google search work efficiently on onKeyPress? because of Caching? In my case, I can't do caching as I need to show realtime data.
I think this is very common issue that almost everyone should have faced. Any better approach?
PS :- Did you notice the onChange event of textbox.It is not same as it is for other elements. It's more like onBlur.
Do not send up on first letter, wait to you have 2+
Limit the number of results that comeback
Cache and filter on the client when the server is able to find all of the matches.
onchange fires when the user removes focus from the textbox and the value is different
Joined: Aug 16, 2007
Eric Pascarello wrote:Limit the number of results that comeback
This is a good option as I am gonna display only 10 results to user.
Eric Pascarello wrote:Cache and filter on the client when the server is able to find all of the matches.
How can I do caching on client side?
Joined: Nov 08, 2001
It is up to you how you code it.
I have an object that links to what the user types. I also have a flag that the server returns saying if there are still more options. If there are not any more options for the server to find, I just use what came from the last call to the server and filter that out.
subject: Improving the performance of Auto Suggestion Box