Tag: 同源策略

不处理“Access-Control-Allow-Origin” – 客户端问题

这个问题对许多新手来说可能不是一个新问题。 我是其中之一,我必须在客户端处理这个问题。 所以,请不要将此问题标记为重复。 我有我的网站客户端代码部署在服务器,这个网站调用部署在其他一些不同的服务器的web服务。 (请注意:我没有这个webservice代码访问)。 我的AJAX代码来检索数据: $.ajax({ type: 'GET', url: 'http://webservice_url', success: function (data) { //success }, failure: function(error){ //error } }); 在通过AJAX访问此Web服务时,我收到: XMLHttpRequest cannot load http://webservice_url. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. 浏览器控制台日志 我可以在浏览器控制台(在我的web服务的“networking”选项卡 – >“响应”选项卡下)成功查看我的web服务的响应。 但是,检索上述错误。 在回顾许多以前的post,我发现通过设置响应标题为: response.addHeader("Access-Control-Allow-Origin", "*"); 将解决这个问题。 但是, 我没有访问权限来改变我的web服务代码,添加响应头 。 […]