How to config WAMP apache server to allow cross domain requests of ajax?

☆樱花仙子☆ 提交于 2019-12-13 16:14:29

问题


I am working on an sencha-touch-2.1.0-based application.The application deals with some cross-domain requests.

We wrapped the js files with Android code with PHONEGAP to make the application run in a Android Phone.

And i have installed the wamp server whose apache version is 2.4.4.

I want to test the UI of the app in a Android Phone browser,so i put the src files of the sencha touch application in the www directory of the apache server of the WAMP.

But i have got an request error in the console of Chrome in PC:

    Origin http://192.168.1.102 is not allowed by Access-Control-Allow-Origin.//192.168.1.102 is the ip of my WAMP server.

After hours in google,i find an easy way like

`<IfModule mod_headers.c>
    Header set Access-Control-Allow-Origin: *
</IfModule>`

way to alter the httpd.conf of the apache server to allow ajax cross domain requests. But it dose not work. So how can i change the httpd.conf of the apache server ?


回答1:


You were on the right track. The only thing left to do now is to enable the headers module. This can be done as follows:

  • click on the wamp icon in your systray
  • go to Apache > Apache modules
  • check the option 'headers_module'

After you do this, wamp will restart and the configuration you put in your post will work



来源:https://stackoverflow.com/questions/18712766/how-to-config-wamp-apache-server-to-allow-cross-domain-requests-of-ajax

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!