我正在创建xhr调用argumnets:
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”。
如何在上面的场景中动态设置标题属性名称。 我想内联。
答案 0 :(得分:0)
尝试改为
var xhrArgs = {
...
headers : {
"Content-Type": "application/json",
"Accept" : "application/json",
"REMOTE_USER" : "admin"
}
};
xhrArgs['headers'][CUSTOM_HEADER] = "abc";