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");

posted @ 2019-12-16 09:59  星星下的石头  阅读(770)  评论(0编辑  收藏  举报