我有这个代码
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..我做错了什么?有没有其他方法来验证url?
发布于 2011-06-30 05:12:09
你需要告诉它使用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://jsfiddle.net/ZD9Y6/证明。
参考
http://code.google.com/apis/youtube/2.0/reference.html#Video_Feeds
http://code.google.com/apis/youtube/2.0/developers_guide_json.html
https://stackoverflow.com/questions/6523296
复制相似问题