拒绝设置不安全 header "Connection" extjs4

Refused to set unsafe header "Connection" extjs4

我尝试使用 extjs 4 post 数据,但我被拒绝设置不安全 header "Connection" 这个例外。

这是我用来 post 数据的函数。

function postDataAsParamsINN(params, url, success, failure, comp) {
    if (comp) {
        comp.getEl().mask('Loading...');
    }
    Ext.Ajax.request({
        url : url,
        method : 'POST',
        params : params,
        headers : {'Connection':'close'},
        success : function(response, opts) {
            if (comp)
                comp.getEl().unmask();

            var resp = Ext.decode(response.responseText);
            if (success)
                success(resp);
        },
        failure : function(response, opts) {
            if (comp)
                comp.getEl().unmask();

            if (failure)
                failure(response);
            else {
                showDefaultFailureMsgINN();
            }
        }
    });
}

这就是我的使用方式。

text : 'Get Forms',
                    iconCls : 'button-with-icon icon-search',
                    id : 'btnGetForms',
                    disabled : false,
                    handler : function(btn, pressed) {
                        if(flightId == null){
                            Ext.Msg.alert("Please select a Flight to see its forms")
                        }
                        else{                                                         

postDataAsParamsINN({flightId:flightId},flightFormListUrl,function(resp){                       
                                Ext.Msg.alert("show the forms with flight id : " + flightId + resp.succes)
                                });
                            }
                        }

提前致谢。

Ajax 请求不允许设置连接 header。看到这个 other answer.

删除这一行:

headers : {'Connection':'close'},

那你应该没有任何问题,你为什么要尝试设置它?我认为它应该只显示为警告,因为浏览器应该忽略它。不同的浏览器可能会有不同的处理方式。