Request header field Content-Type is not allowed by Access-Control-Allow-Headers跨域

跨域错误提示:

XMLHttpRequest cannot load http://xxx.com. Request header field Content-Type is not allowed by Access-Control-Allow-Headers.

 

解决方案:

例如php服务端程序设置头:

header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
header('Access-Control-Allow-Methods: GET, POST, PUT,DELETE');

 

主要是这三个:

 

 

你可能感兴趣的:(PHP深入实践)