Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 使用ajax获取youtube oembed json_Jquery_Ajax_Json_Youtube_Oembed - Fatal编程技术网

Jquery 使用ajax获取youtube oembed json

Jquery 使用ajax获取youtube oembed json,jquery,ajax,json,youtube,oembed,Jquery,Ajax,Json,Youtube,Oembed,我试图用ajax获取youtube链接的嵌入代码,但它总是返回错误 我在Jquery中使用ajax $.ajax({ method: 'GET', dataType :'json', url:'http://www.youtube.com/oembed?url=http://www.youtube.com/watch?v=wbp-3BJWsU8&format=json', success:function(data)

我试图用ajax获取youtube链接的嵌入代码,但它总是返回错误 我在Jquery中使用ajax

    $.ajax({
        method: 'GET',
        dataType :'json',
        url:'http://www.youtube.com/oembed?url=http://www.youtube.com/watch?v=wbp-3BJWsU8&format=json',
        success:function(data){
            alert(data);
        },
        error: function(error) {
            alert(error);
        }
    });
试试下面的方法

 $.ajax({
            url: 'http://query.yahooapis.com/v1/public/yql',
                data: {
                    q: "select * from json where url ='http://www.youtube.com/oembed?url=http://www.youtube.com/watch?v=wbp-3BJWsU8&format=json'",
                    format: "json"
                },
                dataType: "jsonp",
            success: function (data) {

                alert(JSON.stringify(data));


            },
            error: function (result) {
                alert("Sorry no data found.");
            }
        });
试试下面的方法

 $.ajax({
            url: 'http://query.yahooapis.com/v1/public/yql',
                data: {
                    q: "select * from json where url ='http://www.youtube.com/oembed?url=http://www.youtube.com/watch?v=wbp-3BJWsU8&format=json'",
                    format: "json"
                },
                dataType: "jsonp",
            success: function (data) {

                alert(JSON.stringify(data));


            },
            error: function (result) {
                alert("Sorry no data found.");
            }
        });
试试这个:-

现场演示:-

试试这个:-

现场演示:-


使用它…你会得到你的回应…仅此而已…我不知道为什么它真的很有趣!!!谢谢关于YQL的提示:)@BahadırÖzkan,看:使用它…你会得到你的回应…仅此而已…我不知道为什么这真的很有趣!!!谢谢关于YQL的提示:)@BahadırÖzkan,见: