如何在wampserver上允许ACCESS-CONTROL-ALLOW-ORIGIN aka跨域 [英] how to allow ACCESS-CONTROL-ALLOW-ORIGIN aka cross-domain on wampserver

查看:298
本文介绍了如何在wampserver上允许ACCESS-CONTROL-ALLOW-ORIGIN aka跨域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

XMLHttpRequest无法加载 https://webservice.com?param=hahah 。 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跨域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆