http - autocomplete through ajax -


i want suggest results using auto-complete. need send ajax requests on each keystroke. want keep http connection open few seconds , if typed within period, want send ajax in same connection. if nothing typed in period, want close http connection.

background:

i use typewatch plugin. here http connections made each time send request. still want improve speed. read in thread http://www.philwhln.com/quoras-technology-examined#the-search-box that:

quora uses persistent connections. http connection established server when start typing search query.

how can cross browser support? keep-alive?

you can't. each request-response round trip asynchronous, meaning when it's sent, waits particular request's response return, handles it.

what think want prevent script hammering server. there variety of methods, common use keystroke timer. timer waits specified number of milliseconds after user finishes typing before sending request, containing textbox's value, server.

if you're using jquery can use typewatch plugin this. jquery satisfy cross browser requirements.

however, since want auto-complete, may use jquery autocomplete plugin has keystroke timer built in, default it's set 400 millseconds. click options tab on this page see configuration options can pass plugin.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -