The following will do the trick i guess: var timeout; $('#search').keyup(function(){ clearTimeout(timeout); timeout = setTimeout($.ajax(),200); }
On Fri, Apr 24, 2009 at 2:46 PM, Dragon-Fly999 <dragon-fly...@hotmail.com>wrote: > > Hi, my page allows the user to enter a number in a text box and a > search request is sent to the server (if the user stops typing for 200 > ms) using AJAX. The following is the desired behavior. > > (1) User starts typing a number in the text box. As the user is > typing, no search requests are sent to the server. > (2) Once the user stops typing (i.e. no key events for 200 ms), use > $.post() to execute a search. > > What is a good way to detect that the user hasn't typed anything for > 200 ms? Is there anything in JQuery that I can use? Thank you.