第一步:配置Php 后台允许跨域
<?phpheader(‘Access-Control-Allow-Origin: *‘);header(‘Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept‘);//主要为跨域CORS配置的两大基本信息,Origin和headers
第二步:配置Apache web服务器跨域(httpd.conf中)
原始代码
<Directory /> ???AllowOverride none ???Require all denied</Directory>
改为以下代码
<Directory /> ???Options FollowSymLinks ???AllowOverride none ???Order deny,allow ???Allow from all</Directory>
第三部,重启apache
ajax 跨域解决方案
原文地址:https://www.cnblogs.com/blts/p/9212514.html