Ajax CORS POST未在FF上与Apache一起工作

Ajax CORS POST未在FF上与Apache一起工作,ajax,tomcat,cors,Ajax,Tomcat,Cors,我正在尝试从Firefox到我的Tomcat服务器进行CORS POST调用。Tomcat提供RESTful服务。这是我的服务器端返回代码: ResponseBuilder rb = Response.ok( JSON.serialize(result)); rb.header("Content-Type", "text/javascript;charset=utf8"); rb.header("Access-Control-Allow-Orig

我正在尝试从Firefox到我的Tomcat服务器进行CORS POST调用。Tomcat提供RESTful服务。这是我的服务器端返回代码:

        ResponseBuilder rb = Response.ok( JSON.serialize(result));

        rb.header("Content-Type", "text/javascript;charset=utf8");
        rb.header("Access-Control-Allow-Origin", "*");
        rb.header("Access-Control-Max-Age", "3628800");
        rb.header("Access-Control-Allow-Methods", "GET,POST");

        return rb.build();
这是我的AJAX调用:

var feedQueryPOST = {"param" : someListOfParams, "timeWindow": 36000};

     $.ajax({
        type: 'POST',
        url:"http://xxx.xxx.xxx.xxx:8080/MyWebService/getwebfeed",
        contentType: "text/plain",
        data: feedQueryPOST,
        async: true,
        success:function(json){
            alert("success!");
        },
        error:function(e){
            alert(JSON.stringify(e));
        },
     });
当我执行测试查询时,我使用RESTClient检查标头,它返回为:

Status Code: 200 OK
Access-Control-Allow-Methods: GET,POST
Access-Control-Allow-Origin: *
Access-Control-Max-Age: 3628800
Content-Length: 318
Content-Type: text/javascript;charset=utf8
Date: Mon, 31 Dec 2012 12:02:11 GMT
Server: Apache-Coyote/1.1

但是在我的javascript端,回调仍然会出错,readystate=0,status=0。我四处寻找答案已经很长时间了,但没有结果。我知道我可能错过了一些简单的东西。感谢您的帮助,请提前感谢。

使用
数据类型:“json”
而不是
内容类型:“text/plain”
,您应该很好

尝试设置
rb.header(“访问控制允许头”,“内容类型”)