0

我正在创建 xhr 调用参数:

var CUSTOM_HEADER = "XAppName";
.
.
var xhrArgs = {
url: "../../rest/getCustomerData,
postData: dojo.toJson(custJSONObj),
handleAs: "json",
headers: { "Content-Type": "application/json", "Accept" : "application/json","REMOTE_USER" : "admin", CUSTOM_HEADER: "abc"}
}

当我发布此请求时,在请求标头中,CUSTOM_HEADER 显示为请求标头属性而不是“XAppName”。

上述场景中如何动态设置头部属性名。我想内联。

4

1 回答 1

0

试试吧

 var xhrArgs = {
    ...
    headers : { 
       "Content-Type": "application/json", 
       "Accept" : "application/json",
       "REMOTE_USER" : "admin"
    }
 };

 xhrArgs['headers'][CUSTOM_HEADER] = "abc";
于 2013-03-05T12:16:04.210 回答