跨域请求Access to XMLHttpRequest at 'http://localhost/index.php/api/user/login'
时间:2020-04-01 22:08:16
收藏:0
阅读:2335
ajax访问后台接口遇到报错
解决方法:
在被请求的php文件中加入请求头部
header(‘Access-Control-Allow-Origin: *‘);
例如: 我的后台接口是用laravel框架写的,所以在laravel的index.php中加入请求头部
后台返回的数据
评论(0)