php写接口跨域问题

转:https://blog.csdn.net/unhejing/article/details/78600694

在后台写接口获取不到数据的时候,控制台提示跨域问题,可以在控制器里面传输数据前加入如下代码

header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods:POST,GET");
header("Access-Control-Allow-Headers:x-requested-with,content-type");
header("Content-type:text/json;charset=utf-8");

猜你喜欢

转载自www.cnblogs.com/whatstone/p/12047625.html