Skip to content

Instantly share code, notes, and snippets.

@BforBen
Created May 9, 2014 07:17
Show Gist options
  • Save BforBen/0a273296464fc099897a to your computer and use it in GitHub Desktop.
Save BforBen/0a273296464fc099897a to your computer and use it in GitHub Desktop.
JavaScript for "Bootstrap Typeahead with Google Custom Search autocomplete"
var GoogleCseAutoComplete = function (query, process) {
$.ajax({
url: 'https://clients1.google.com/complete/search?q=' + query + '&hl=en&client=partner&source=gcsc&partnerid={YOUR_GOOGLE_CSE_CODE}=cse&nocache=' + Math.random().toString(),
dataType: 'jsonp',
success: function (data) {
process($.map(data[1], function (item) { return item[0]; }));
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment