跨域问题服务端解决办法
一般在入口文件加
header('Access-Control-Allow-Origin:*'); // 响应类型 header('Access-Control-Allow-Methods:*'); // 响应头设置 header('Access-Control-Allow-Headers:content-type,token,id'); header("Access-Control-Request-Headers: Origin, X-Requested-With, content-Type, Accept, Authorization");
都能解决,要是不行试试下面
if($_SERVER['REQUEST_METHOD'] == 'OPTIONS'){ header("Access-Control-Allow-Origin: *"); header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization"); header('Access-Control-Allow-Methods: GET, POST, PUT,DELETE,OPTIONS,PATCH'); file_put_contents('option.txt',json_encode($_REQUEST)); exit; } header('Access-Control-Allow-Origin:*'); // 响应类型 header('Access-Control-Allow-Methods:*'); // 响应头设置 header('Access-Control-Allow-Headers:content-type,token,id'); header("Access-Control-Request-Headers: Origin, X-Requested-With, content-Type, Accept, Authorization");
要是还不行,你自裁吧!