Question: I've build a livesearch with the jQuery.ajax() method. On every keyup events it receives new result data from the server.

The problem is, when I'm typing very fast, e.g. "foobar" and the GET request of "fooba" requires more time than the "foobar" request, the results of "fooba" are shown.

To handle this with the timeout parameter is impossible, I think.

Has anyone an idea how to solve this?

Answer: 
You can store and [`.abort()`](http://www.w3schools.com/dom/dom_http.asp) the last request when starting a new one, like this:

```
var curSearch;
$("#myInput").keyup(function() {
  if(curSearch) curSearch.abort(); //cancel previous search
  curSearch = $.ajax({ ...ajax options... }); //start a new one, save a reference
});

```

The [`$.ajax()`](http://api.jquery.com/jQuery.ajax/) method returns the [XmlHttpRequest](http://www.w3schools.com/dom/dom_http.asp) object, so just hang onto it, and when you start the next search, abort the previous one.
You will want some kind of an ajax queue such as:

<http://plugins.jquery.com/project/ajaxqueue>

or <http://www.protofunc.com/scripts/jquery/ajaxManager/>

EDIT:Another option, study the Autocomplete plug-in code and emulate that.(there are several Autocomplete as well as the one in jquery UI
OR just implement the Autocomplete if that serves your needs