I am making a JSONp call to youtube using oembed and on response firebug gives "invalid label" error
Here is my code
site = "www.youtube.com";
url = "http://www.youtube.com/watch?v=slORb622ZI8";
$.getJSON("http://"+site+"/oembed?callback=?",{"format":"json","url":url},function(data){
alert("hello:\n"+data);
alert(data.provider_url);
});
Anyone ran into similar problem with oembed jsonp requests?
YouTube API doesn't support JSONP - see:
There is no need for a server-side proxy and no API keys are required.
Instead of:
var url = "http://www.youtube.com/watch?v=slORb622ZI8";
$.getJSON("http://www.youtube.com/oembed?callback=?",
{"format": "json", "url": url}, function (data) {
alert("hello:\n"+data);
alert(data.provider_url);
});
Try this, using the Noembed service:
var url = "http://www.youtube.com/watch?v=slORb622ZI8";
$.getJSON("https://noembed.com/embed?callback=?",
{"format": "json", "url": url}, function (data) {
alert("hello:\n" + data);
alert(data.provider_url);
});
As a bonus this will also work with Vimeo links when you change url
to:
var url = "https://vimeo.com/45196609";
and many other supported sites.
See DEMO on JS Fiddle.
See also those questions:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With