我正在使用 ajax 发出发布请求(CORS
)并且我正在设置一个标题(Content-Type:application/x-www-form-urlencoded
)并且我正在尝试读取响应的标题。这是我所做的:
function makePostRequest(url, data, headers, httpVerb, dataType, elementId) {
$.ajax({
url: url,
type: httpVerb,
data: data,
headers: headers,
dataType: dataType,
success: function(data, textStatus, jqXHR) {
$("#" + elementId).val(jqXHR.responseText);
alert(JSON.stringify(jqXHR));
},
error: function(jqXHR, textStatus, errorThrown) {
$("#" + elementId).val(jqXHR.responseText);
}
}).then(function(data, status, xhr) {
console.log(xhr.getAllResponseHeaders());
});
}
但在控制台中仅打印
Content-Type: application/x-www-form-urlencoded; charset=utf-8
And in chrome developer tools I'm seeing:
![enter image description here](https://i.stack.imgur.com/09nBc.png)
如何获取所有这些标头?
PS:我使用的是 Chrome,而不是 Firefox ()
我问如何获取所有标头,而不是为什么我只得到一个标头(如果不可能,我会接受这个答案)。