A lightweight and extensible type ahead library
new TypeAhead(document.getElementById('type-ahead'), [ 'Asia', 'Africa', 'North America', 'South America', 'Antarctica', 'Europe', 'Australia' ]);
var t = new TypeAhead(document.getElementById('type-ahead')), xhr; t.getCandidates = function (callback) { if (xhr) { xhr.abort(); } xhr = $.getJSON('https://clients1.google.com/complete/search?client=youtube&tok=Iu2UFybBVjvwBqGBmnMaKw&callback=?&q=' + this.query, function (response) { var candidates = []; for (var i = 0; i < response[1].length; i++) { candidates.push(response[1][i][0]); } callback(candidates); }); };