如何使用YouTube的类别对jQuery UI-autocomplete进行分类

时间:2015-11-20 20:56:48

标签: jquery-ui-autocomplete

我正在使用 jQuery UI-autocomplete 从YouTube获取wordlist,我使用了此处提供的代码:How to get the wordlist from youtube search for Jquery UI autocomplete?

我想知道是否可以按类别从YouTube自动填充,例如,YouTube的类别音乐。

$("#q").autocomplete({
    source: function(request, response){
        /* Need a api key for this, so we add it:  */
        var apiKey = 'MYAPIKEY';
        /* command */
        var query = request.term;
        /* youtube ajax request */
        $.ajax({
            url: "http://suggestqueries.google.com/complete/search?hl=en&ds=yt&client=youtube&hjson=t&cp=1&q="+query+"&key="+apiKey+"&format=5&alt=json&callback=?",  
            dataType: 'jsonp',
            success: function(data, textStatus, request) { 
               response( $.map( data[1], function(item) {
                    return {
                        label: item[0],
                        value: item[0]
                    }
                }));
            }
        });
    },
    /* seçilene işlem yapmak için burayı kullanabilirsin */
    select: function( event, ui ) {

    }
});

0 个答案:

没有答案