我正在尝试使用 Polymer 进行跨域调用核心ajax http://www.polymer-project.org/docs/elements/core-elements.html#core-ajax成分。我不断收到请求的资源上没有“Access-Control-Allow-Origin”标头。我的组件代码如下
<core-ajax id="ajax"
auto
url="http://api.meetup.com/2/event_comments/?key=MyKey&event_id=191593992&callback=?"
on-core-response="{{commentsLoaded}}"
method='GET'
contentType='text/javascript'
handleAs="json">
</core-ajax>
如果我使用 jQuery 和下面的代码片段,它就可以工作
$.getJSON('http://api.meetup.com/2/event_comments/?key=MyKeyc&event_id=191593992&callback=?')
所以我想我的问题是 jQuery 使用 Polymer 没有什么巫毒魔法,我该如何解决它?我检查了控制台,一切看起来都一样(标头、参数等)。
正如 Jason P 在上面的评论中指出的那样,您可以在此处使用polymer-jsonp。
<polymer-jsonp
auto
url="http://api.meetup.com/2/event_comments/?key=MyKeyc&event_id=191593992&callback="
on-polymer-response="{{commentsLoaded}}">
</polymer-jsonp>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)