Embed youtube videos using oembed Embed youtube videos using oembed json json

Embed youtube videos using oembed


Actually the problem is you're violating the browser same origin policy with a cross domain ajax request. There a few work potential work arounds -- unfortunately the best JSONP, isn't implemented by YouTube. The next best is using Flash for transport. This is used by YUI-IO utility. Also you can see Jquery suggestions here.


I get the json data just fine if I embed the raw trololo url in the oembed url. I'm guessing that by typing in the encoded version into the address bar does a layer of decoding anyways, so try just sending the raw one:

http://youtube.com/oembed?url=http://www.youtube.com/watch?v=iwGFalTRHDA&format=json


Use the json-c version: https://developers.google.com/youtube/2.0/developers_guide_jsonc

    var id = "iwGFalTRHDA";    $.ajax({        url: "https://gdata.youtube.com/feeds/api/videos/" + id + "?v=2&alt=jsonc",        dataType: "jsonp",        success: function (data) {            console.log(data);        }    });