Google suggestions are put online as an XML sheet, for instance these are suggestions for the word stack: XML results by Google. Here’s a truncated version:
<toplevel>
<CompleteSuggestion>
<suggestion data="stack overflow"/>
<num_queries int="25200000"/>
</CompleteSuggestion>
<CompleteSuggestion>
<suggestion data="stackable washer dryer"/>
<num_queries int="1050000"/>
</CompleteSuggestion>
<CompleteSuggestion>
<suggestion data="stacked"/>
<num_queries int="57000000"/>
</CompleteSuggestion>
…
</toplevel>
I want to put an input field on my website and get the suggestions while typing. How would I get the XML and show it like regular HTML(text) on my website?
(Can I do this with jQuery??)
To retrieve the XML data cross-domain you can use YQL to retrieve the data and transform them into JSONP.
For showing the suggestion you can use jQuery UI’s Autocomplete.
HERE is the code.