XMLHttpRequest setRequestHeader() - >有没有办法设置标头值,而不是附加到它?

时间:2012-08-02 19:22:04

标签: javascript jquery django xmlhttprequest

来自:http://www.w3.org/TR/XMLHttpRequest/#the-setrequestheader-method

client.setRequestHeader() 
    Appends an header to the list of author request headers, or if
    header is already in the list of author request headers, combines 
    its value with value.

Q值。有没有办法设置标题而不是附加到现有标题?

我正在使用的代码如下,基本上是从https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax复制并粘贴的代码:

jQuery(document).ajaxSend(function(event, xhr, settings) {
     ...

     // xhr is an XMLHttpRequest object
     xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken'));
}

0 个答案:

没有答案