Вопрос

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);
        }
    });
Это было полезно?

Решение

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.");
            }
        });

Другие советы

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.");
            }
        });
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top