您好,欢迎访问一九零五行业门户网

ajax提交下出现这种失败怎么处理啊?

我已经添加了 header(access-control-allow-origin:*);
但还是返回错误信息:
response to preflight request doesn't pass access control check: no 'access-control-allow-origin' header is present on the requested resource. origin 'http://127.0.0.1:10860' is therefore not allowed access.
翻译:
针对预检要求不能通过访问控制检查:没有访问控制允许源头是目前对请求的资源。http:/ / 127.0.0.1:10860起源”因此不允许访问。
怎么处理这种错误啊
回复内容: 我已经添加了 header(access-control-allow-origin:*);
但还是返回错误信息:
response to preflight request doesn't pass access control check: no 'access-control-allow-origin' header is present on the requested resource. origin 'http://127.0.0.1:10860' is therefore not allowed access.
翻译:
针对预检要求不能通过访问控制检查:没有访问控制允许源头是目前对请求的资源。http:/ / 127.0.0.1:10860起源”因此不允许访问。
怎么处理这种错误啊
chrome的报错挺搞笑的
只要是跨域的请求,返回值大于等于400,就会报这一条错误(警告?)。
具体看看请求有没有返回值。(chrome中切到network栏)
请求跨域了
同一域名的不同端口之间请求通信也算跨域,受浏览器同源策略保护,请求被中断。
具体解决方案可以看这篇博客
http://www.cnblogs.com/rainman/archive/2011/02/20/1959325.html#m0
你抓用一些请求,会发现post请求前面还有一个option请求。你可以查一下资料preflight request
感觉还是response的返回头上没加上,access-control-allow-origin,能否看下控制台,这条请求的返回头呢?看看返回头中是否有这个字段。
这个错误就是跨域的错误。
其它类似信息

推荐信息