I have a Java server that I am sending application/json POST request to and returning 204 No Context Responses with 2 headers at a certain endpoint. But in my Javascript code I don't get the headers. This is cross-origin
When I test in Postman I am able to see these two headers, but in JavaScript (using Ajax and jQuery) I get a 204 Response with no headers. My Java server receives the request and processes it normally.But somehow the Javascript does not get headers. This is cross-origin
Update:Same thing happens with 200 Response. Postman gets the headers but not Javascript
$.ajax({ 'type': 'POST', 'url': url, 'contentType': 'application/json', 'data': JSON.stringify(data), 'dataType': 'json', success:login }); In the login function I try to log some values
function login(data, statusText, response) { var status = response.status; console.log(status) var headers = response.getAllResponseHeaders(); console.log(response) console.log(headers) var transID = response.getResponseHeader("transactionID"); console.log(transID) } Status correctly shows 204, headers is an empty string, and transID is null. I am confident the Java server is putting the headers in the response because my Postman tests display them
The url is the Java server running on localhost so I didn't include it
login()where you attempt to read these headers.