嗨,我只想简单地从youtube获取一个网址并表示html内容。我的代码现在看起来像这样:
$.ajax({url: "http://www.youtube.com/watch?v=VIDEOID",
type: 'get',
dataType:'jsonp',
crossDomain:true,
success: function(data,text,xhqr){
console.log(data);
}
});
结果是:
Resource interpreted as Script but transferred with MIME type text/html: "http://www.youtube.com/watch?v=rr5EyyhSU_k&callback=jQuery110209012887296266854_1387530192875&_=1387530192876". jquery.js:8516 Uncaught SyntaxError: Unexpected token <
而且我没有数据...有人可以帮助我吗?:)
试试这个,
$.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.");
}
});