我有这个代码
var x = 'http://gdata.youtube.com/feeds/api/videos/FLE2htv9oxc';
var myJSONP = new Request.JSONP({
url: x,
callbackKey: 'jsoncallback',
data: ({ partTag: is_youtube }),
onRequest: function (url) {
// a script tag is created with a src attribute equal to url
},
onComplete: function (data) {
// the request was completed.
alert("ok");
}
}).send();
我尝试验证youtube视频是否存在 我一直收到这个错误
失踪;在声明之前 [打破此错误] ... ount ='193'viewCount ='19488'/>
arrr .. 我究竟做错了什么 有没有办法以任何其他方式验证网址
答案 0 :(得分:0)
你需要告诉它使用v2和jsonp。就目前而言,它返回xml ...
var x = 'http://gdata.youtube.com/feeds/api/videos/FLE2htv9oxc?v=2&alt=jsonc';
var myJSONP = new Request.JSONP({
url: x,
log: true,
onRequest: function(url) {
// a script tag is created with a src attribute equal to url
},
onComplete: function(data) {
// the request was completed.
console.log(data);
}
}).send();
<强>引用强>
http://code.google.com/apis/youtube/2.0/reference.html#Video_Feeds
http://code.google.com/apis/youtube/2.0/developers_guide_json.html