无法进行跨域Ajax调用

$(document).ready(function(){$ .ajax({url:“

http://gdata.youtube.com/feeds/api/users/zdf/playlists?v=2

”,键入:“ GET”,成功:function(msg){console.log(msg);}});});

我收到此错误“

XMLHttpRequest无法加载http://gdata.youtube.com/feeds/api/users/zdf/playlists?v=2

我如何进行跨域Ajax调用以从api获取xml?

回答:

您不能进行跨域调用来获取XML。跨域接收数据的唯一选择是JSON-P

same origin policy限制直接进入外域(AJAX / I帧),json-p用途dynamic script tag

insertion,以解决此问题。

看看http://api.jquery.com/jQuery.getJSON/。JSON-P也覆盖在那里。

http://code.google.com/intl/de-

DE/apis/youtube/2.0/developers_guide_json.html

为您量身定做!

以上是 无法进行跨域Ajax调用 的全部内容, 来源链接: utcz.com/qa/404456.html

回到顶部