Created
June 1, 2017 02:48
-
-
Save dovidezra/06e716b7af65bd14368ad92c32bf313b to your computer and use it in GitHub Desktop.
CDN hosted jQuery based Autocomplete script with Millions of Suggestions. Details: https://knowledgebasehub.com
This file contains hidden or 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 KnowledgebaseHub; | |
$(document).ready(function () { | |
$("#search").autocomplete({ | |
source: function(request, response) { | |
$.getJSON("https://suggestqueries.google.com/complete/search?callback=?", | |
{ | |
"hl":"en", // "en" is english. see documentation for more languages | |
"ds":"", // Force youtube suggestions, use "yt" | |
"jsonp":"KnowledgebaseHub", // jsonp callback function name | |
"q":request.term, // search term | |
"client":"youtube" // force jsonp response | |
} | |
); | |
KnowledgebaseHub = function (data) { | |
var suggestions = []; | |
$.each(data[1], function(key, val) { | |
suggestions.push({"value":val[0]}); | |
}); | |
suggestions.length = 5; // show upto 10 suggestions | |
response(suggestions); | |
}; | |
}, | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment