Google Auto Suggest by country

I would like to create a search box that returns google auto tips from different countries. I found this great example of recreating an autocomplete search:

http://jsfiddle.net/XxTuA/2/

var suggestCallBack; // global var for autocomplete jsonp $(document).ready(function () { $("#search").autocomplete({ source: function(request, response) { $.getJSON("http://suggestqueries.google.com/complete/search?callback=?", { "hl":"en", // Language "jsonp":"suggestCallBack", // jsonp callback function name "q":request.term, // query term "client":"youtube" // force youtube style response, ie jsonp } ); suggestCallBack = function (data) { var suggestions = []; $.each(data[1], function(key, val) { suggestions.push({"value":val[0]}); }); suggestions.length = 5; // prune suggestions list to only 5 items response(suggestions); }; }, }); }); 

but I can’t figure out how to limit it to a specific country, and there seems to be no documentation about the parameters that can be passed to google auto.

If anyone has suggestions on how to do this, that would be great. Thanks!

+4
source share
1 answer

Autocomplete suggestions are determined by language not by country.

Just install hl in another language.

See this script for more details: http://jsfiddle.net/ArtBIT/x8yfm/

+2
source

All Articles