ajax跨域请求常见解决办法

ajax常见跨域解决办法:

第一步:在请求的php代码页加上:

1 header('Access-Control-Allow-Origin: *');
2 header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept');

第二步:配置Apache web服务器跨域(httpd.conf中)将原始代码:

1 <Directory />
2     AllowOverride none
3     Require all denied
4 </Directory>

改为:

1 <Directory />
2     Options FollowSymLinks
3     AllowOverride none
4     Order deny,allow
5     Allow from all
6 </Directory>

以上两步操作基本可以解决所有ajax跨域问题。

 

posted @ 2019-07-19 16:04  追梦鑫求  阅读(161)  评论(0)    收藏  举报