Firstly, search the suggestion words array from google:
var the_url = 'http://suggestqueries.google.com/complete/search?hl=en&ds=yt&client=youtube&hjson=t&jsonp=window.yt.www.suggest.handleResponse&q='+encodeURIComponent(searchBox.val())+'&cp=1';
$.ajax({
type:
"GET",
url: the_url,
dataType:
"script"
});
Secondly, load video from youtube videos api:
type: "GET",
"jsonp",
success:
function(responseData, textStatus, XMLHttpRequest) {
if (responseData.data.items) {
updateVideoDisplay(responseData.data.items);
}
else {
updateSuggestedKeyword(
'No results for "'+keyword+'"');
doneWorking();
others is something typing call real time states changing.