CORS不适用于Chrome [英] CORS not working on Chrome

查看:158
本文介绍了CORS不适用于Chrome的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在服务器(Jetty使用CrossOriginFilter)上设置了跨源资源共享,它在IE8和Firefox上完美工作。在Chrome上,只是...不。

I've set up Cross-Origin Resource Sharing on a server (Jetty using the CrossOriginFilter) and it works perfectly on IE8 and Firefox. On Chrome, it just ... doesn't.

  $.ajax({ url : crossOriginURL,
    type : "GET",
    error : function(req, message) {
        alert(message);
    },
    dataType :  "json" } );

调用错误函数,并显示帮助信息error。它似乎在做请求,但没有任何标题,你会期望。如果URL来自同一个来源,它工作正常。

The error function is invoked, with the helpful message "error". It seems to be making the request, but without any of the headers you'd expect. If the URL is from the same origin, it works fine.

推荐答案

最终为我工作的是 xhr.setRequestHeader('Content-Type','text / plain');

这篇关于CORS不适用于Chrome的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆