【发布时间】:2012-07-04 04:15:55
【问题描述】:
我将 JSON 对象存储在 Amazon S3 中,我想直接从 Javascript 中的 S3 加载该数据。我的 GET 看起来很一般:
$.ajax({
'type':'GET',
'url':'http://s3.amazonaws.com/mybucketname/'+id,
'dataType':'text',
'success':function(msg) {
alert(msg);
}
});
我收到以下错误:
XMLHttpRequest cannot load http://s3.amazonaws.com/whatever/whatever. Origin http://mylocalhostname:9000 is not allowed by Access-Control-Allow-Origin.
我可以使用 curl 从 S3 获取该 URL,或者直接从我的浏览器导航到那里。我真的必须通过我自己的服务器代理所有这些请求吗?
【问题讨论】:
-
或另一个骗子:stackoverflow.com/questions/8674776/… 显示 JSONP 解决方案。
标签: javascript jquery amazon-s3