本文介绍了让YouTube oembed JSON阿贾克斯的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图让阿贾克斯的YouTube链接oembed code,但它总是返回错误我使用AJAX使用jQuery
$。阿贾克斯({
方法:GET,
数据类型:JSON,
'?HTTP://www.youtube.com/oembed URL = HTTP://www.youtube.com/watch V = WBP-3BJWsU8和放大器;格式= json的网址,
成功:功能(数据){
警报(数据);
},
错误:功能(错误){
警报(错误);
}
});
解决方案
尝试以下
$。阿贾克斯({
网址:http://query.yahooapis.com/v1/public/yql,
数据: {
问:从JSON其中,url =选择*'?://www.youtube.com/oembed URL = HTTP:HTTP //www.youtube.com/watch V = WBP-3BJWsU8和放大器;格式= JSON',
格式为:JSON
},
数据类型:JSONP
成功:功能(数据){
警报(JSON.stringify(数据));
},
错误:函数(结果){
警报(对不起,暂时没有内容。);
}
});
I am try to get oembed code of youtube link with ajax but it returns always errorI 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.");
}
});
这篇关于让YouTube oembed JSON阿贾克斯的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!