javascript - Google Search Bar on website -
i have search bar on website allows user type search , go google search engine.
it works fine.
my question how can make have google auto recommendations come up. example, if types "bas..." regular search in google.com... basketball come along other reccommendations. how can add little search bar on site?
<form method="get" action="https://www.google.com/search">
google "provides" auto-complete jsonp api:
$.ajax({ url: "http://suggestqueries.google.com/complete/search", datatype: "jsonp", data: { client: "chrome", q: "query" } }).done(function(data){ console.log(data); });
data
auto complete data. http://jsfiddle.net/derekl/mwvjx/
a complete working demo: http://jsfiddle.net/derekl/8ftcg/
seems can use mini calculator. :)
this api returns info further text. contains type of every item, title (if link), , relevance index.
ps: sorry if not familiar jquery. when comes xhr , ajax, jquery essential. it's life saver!
Comments
Post a Comment