跨域错误提示:
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');
本文介绍了解决 XMLHttpRequest 跨域请求中出现的 Access-Control-Allow-Headers 错误的方法。通过在 PHP 服务端设置适当的头部信息,可以允许指定的请求头字段,从而避免跨域问题。
5346

被折叠的 条评论
为什么被折叠?



