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跨域问题。
浙公网安备 33010602011771号