Created
May 9, 2014 07:17
-
-
Save BforBen/0a273296464fc099897a to your computer and use it in GitHub Desktop.
JavaScript for "Bootstrap Typeahead with Google Custom Search autocomplete"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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