I'm making a post request with ajax (CORS
) and I am setting a header (Content-Type:application/x-www-form-urlencoded
) and I'm trying to read the response's headers. Here is what I've done:
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());
});
}
But in the console is printed only
Content-Type: application/x-www-form-urlencoded; charset=utf-8
And in chrome developer tools I'm seeing:
How to get all these headers?
PS: I am using Chrome, not Firefox ()
I asked how to get all headers, not why I'm getting only one header(if it's not possible, I will accept this answer).