jQuery.ajax(): discard slow requests -


I did a search with the jQuery.ajax () method. It receives new result data from the server on every keynote event.

The problem is, when I'm typing too fast, e.g. At the request of "FOBR" and "FOOB" requires more time than the "FOOBR" request, results of "FOBA" are shown.

It is impossible to handle it with timeout parameters, I think

Does anyone have to solve this idea?

You can store and request a new start when the last request:

  var curSearch; $ ("# MyInput") key (function () (if curSearch) curSearch.abort (); // Cancel previous search search = $ .ajax ({... AJAX option ...}); // Start a new one, save a reference));  

The method returns the object, so hang it on, and when you start the next search, cancel the previous one.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -