问题描述
XMLHttpRequest无法加载。 Access-Control-Allow-Origin不允许使用原始http:// {domain}。
XMLHttpRequest cannot load https://webservice.com?param=hahah. Origin http://{domain} is not allowed by Access-Control-Allow-Origin.
当我尝试通过wampserver进行网络服务调用时得到了此消息,如何在wampserver上启用它?
I get this when I try to make a webservice call through wampserver, how could I enable this on wampserver?
或者我怎么能用jsonP来获取xml数据而不用JavaScript不会引发错误。
or how may i just jsonP to obtain xml data without javascript throwing an error.
推荐答案
您必须启用标头模块首先,像这样:
You have to enable the headers module first, like so :
- 单击系统托盘中的wamp图标
- 转到Apache> Apache模块
- 选中选项'headers_module'
然后将其包含在apache配置中:
And then include this in your apache config:
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin: *
</IfModule>
(在httpd.conf或您的虚拟主机配置中)
(in httpd.conf or in the configuration of your vhost)
(除了*之外,您还可以指定一个特定域)
(Instead of the * you can also specify a specific domain)
这篇关于如何在wampserver上允许ACCESS-CONTROL-ALLOW-ORIGIN aka跨域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!