XMLHttpRequest cannot load. Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin is therefore not allowed access.
相信看到这个报错,大家心里想到是ajax跨域提示,可能也有人有过这个疑问,明明在后端处理中加了头信息来解决跨域,可控制台还是提示出错
header('Access-Control-Allow-Origin:*'); header('Access-Control-Allow-Methods:POST'); header('Access-Control-Allow-Headers:x-requested-with,content-type');
本人就是遇到了这个问题,然后尝试出了结果,其实罪魁祸首是JQ的版本。
经过测试jq1.4之前可能不太直接友好支持跨域请求。
1.4之后你就可以大胆使用了,控制台也不会抛异常,如果小伙伴们碰到这个错误,不放换个高版本的jq试试吧。
转载请注明:Li Jianwei's Blog » JQ高低版本得ajax跨域请求问题