修改jQuery ajax请求连接头 [英] Modifying jQuery ajax request Connection header

查看:110
本文介绍了修改jQuery ajax请求连接头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下代码修改Connection标头但没有成功

I'm trying to modify the Connection header with the following code with no success

jQuery.ajax({
    url: URL,
    async: boolVariable,
    beforeSend: function(xhr)   
    {
        xhr.setRequestHeader("Connection", "close");
    }   
})

通过Firebug的请求标题显示:

The request headers via Firebug show:

Connection  keep-alive
X-Requested-With    XMLHttpRequest

设置此特定标头的任何奇怪错误/问题都已知?或者有什么我做错了吗?

Any odd bugs/problems with setting this particular header known? Or is there something I'm doing wrong?

推荐答案

根据标准此处您不能设置 Connection 标头。它将终止set头。此外,如果您在webkit中尝试此操作,控制台将输出拒绝设置不安全的标题连接所以看起来您将无法在客户端执行您想要的操作。

According to the standard here you are not allowed to set the Connection header. It will terminate the set header. Also if you try this in webkit the console will output Refused to set unsafe header "Connection" So it looks like you will not be able to do what you want on the client side.

这篇关于修改jQuery ajax请求连接头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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