Execute a function with sliding delay
<p>Say I have an html page which diplays a list of some elements. There is a textbox which allows the user to filter the elements. To update the displayed elements, I need to do an ajax call to retrieve the elements that match the filter value. I want the ajax call to be executed two seconds after the last letter was typed in the filter textbox. I know about <code>settimeout</code> but I want the two second delay to be "sliding", meaning that if within the two second delay period the user types another letter, then I want to reset the delay. How would I go about that? </p>

<p>Thanks in advance.</p>
