I am using the following code for an AJAX call
$.ajax({
type: "POST",
url: "http://******/cxf/view/*****",
data: {*****},
headers: {*****},
success: function (dt, status, request) {
console.log(request.getAllResponseHeaders());
},
error: function (jqXHR, status) {
}
});
This is printing only content-type. In the developer console i can see number of headers in the response. How can i get those headers in AJAX
On your server you need to add
res.header("Access-Control-Expose-Headers", "header-you-want-to-expose");
and then you will be able to access it in the browser.
I used the same code you used
success: function (dt, status, request) {
console.log(request.getAllResponseHeaders());
Problem is not with Jquery or Ajax. Response headers are set by Server. The server you are sending the request to, is not setting the headers! Simple!!!!
When i tried with my server [Some responses blurred for security] i got the following output
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With