Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get youtube oembed json with ajax

I am try to get oembed code of youtube link with ajax but it returns always error I am using ajax with Jquery

    $.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);
        }
    });
like image 681
Bahadır Özkan Avatar asked Dec 21 '25 17:12

Bahadır Özkan


2 Answers

try the following

 $.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.");
            }
        });
like image 157
Ankush Jain Avatar answered Dec 24 '25 10:12

Ankush Jain


Try this :-

live Demo :-

http://jsfiddle.net/YFtvU/8/

$.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.");
            }
        });
like image 28
Harshit Tailor Avatar answered Dec 24 '25 09:12

Harshit Tailor



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!