首页 > 技术文章 > php 跨域请求

scott-j 2018-05-13 07:24 原文

执行要在跨域请求的服务器端对应的代码上增加下面的代码

<?php

namespace Admin\Controller;

// 指定允许跨域访问  
header('Access-Control-Allow-Origin:*');    
header('Access-Control-Allow-Origin:http://你的请求域名');  
header('Access-Control-Allow-Credentials:true');
header('Access-Control-Allow-Methods:GET, POST, PUT, DELETE, OPTIONS');
header('Access-Control-Allow-Headers:X-Requested-With,content-type');

//下面是你的代码

 

推荐阅读