Access to XMLHttpRequest at 'https://zxxxx.com/' from origin 'http://zxxxx.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
如果后端已经设置了跨域,那就是预检跨域请求问题;
如果后端没有设置跨域信息,则是跨域问题,添加一下允许跨域代码即可。
PHP代码设置:(跨域和预检跨域通用)
// 允许 runapi.showdoc.cc 发起的跨域请求header("Access-Control-Allow-Origin: *"); header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Connection, User-Agent, Cookie,Token");//处理跨域预检请求if($_SERVER['REQUEST_METHOD'] == 'OPTIONS'){ //允许的请求类型 header('Access-Control-Allow-Methods: GET, POST, PUT,DELETE,OPTIONS,PATCH'); exit;}
设置:Access-Control-Allow-Methods 允许的类型即可。