user1123379
user1123379

Reputation: 334

jQuery + PHP how to make autocomple like google

When you write somthing on Google, it will keep what you wrote and add gray text as option to complete.

For Example:

[Black]Goo[/black][gray]le[/gray] ( The Black is what you wrote, and gray is possibility to autocomplete )

I tried to do that and success, but it was very slowly even though I use localhost.
So I'm asking for the best way to do this thing.

Upvotes: 0

Views: 311

Answers (2)

Kavi Siegel
Kavi Siegel

Reputation: 2994

Since you're already using jQuery, maybe consider using jQueryUI to handle autocomplete for you. You provide it the url to your PHP page which should just return a json encoded string of results based on $_GET['term'] that jQueryUI will send your url.

http://jqueryui.com/demos/autocomplete/

Upvotes: 1

Milan Babuškov
Milan Babuškov

Reputation: 61208

You can pre-load the list for all possible combinations of the next 2-3 characters into javascript array, and pick from it while you update the list in the background with new characters.

Upvotes: 0

Related Questions