如何从YouTube的搜索jQuery用户界面自动完成的词表? [英] How to get the wordlist from youtube search for Jquery UI autocomplete?

查看:192
本文介绍了如何从YouTube的搜索jQuery用户界面自动完成的词表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚建造基础上的 =htt​​ps://开头developers.google.com/youtube/v3/docs/search/list?hl=hu相对=nofollow>的Youtube API V3
我想补充的自动完成功能来搜索输入,问题是,词表。结果
如果我加入一个大的单词列表,这意味着更大的加载时间,并自动完成是没用的,因为你需要编写出完整的单词,为得到你正确的单词,如果我增加一个小词表,负载时间为好,但问题是一样的,自动完成是没用的,因为这么想的完成任何有用的。
于是,我以不同的方式看​​这个问题。
那么如果我不知何故,我得到了YouTube的自动完成单词表,基于相关性,而单词表只有加载,当你打字。
那可能吗?

I just builded my own youtube search based on Youtube API V3. I would like to add auto complete function to search input, the problem is, the wordlist.
If I add a big word list, that means a bigger load time, and the autocomplete is useless, because you need to write out the full word, for get your correct word, if I add a small wordlist, the load time is good, but the problem is same, the autocomplete is useless, because dosen't complete any useful. So I looked this problem in a different way. What about if I somehow I get the youtube autocomplete wordlist, based on relevance, and the wordlist only then loaded, when you typing. Is that possible?

推荐答案

有了这么多的研究,我发现了一个解决方案:

With so many research I found a solution for this:

$("#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 ) {

    }
}); 

我希望它也帮助别人谁找了这样的事情。

I hope it help also someone else who looking for a something like this.

这篇关于如何从YouTube的搜索jQuery用户界面自动完成的词表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆