【发布时间】:2015-07-24 09:44:28
【问题描述】:
我正在尝试做一个非常简单的任务 - 使用 AngularJS 获取网站的 html 内容。这是我的代码:
$http({method: 'GET', url: "http://www.google.com",
headers:{
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
'Access-Control-Allow-Headers': 'Content-Type, X-Requested-With'
}})
.success(function(d){ console.log( "yay" ); })
.error(function(d){ console.log( "nope" ); });
问题是我收到CORS 错误:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
我对@987654325@ 问题非常熟悉,我知道这主要是服务器问题。但是,任何人都可以建议(如果可能的话)解决我的问题吗?
【问题讨论】:
标签: javascript angularjs cors