跨域错误提示:
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, x-file-name");
header('Access-Control-Allow-Methods: GET, POST, PUT,DELETE');
其实主要是看console返回的错误信息,适当修改以上代码的参数。哪个被拒绝了,就添加哪一个。