0

Is it possible to set a custom header as part of a GET response from the server-side, and retrieve its value using JavaScript/JQuery on the client side once the response is received?

If so, what is the proper way of doing this in JavaScript?

MLister
  • 10,022
  • 18
  • 64
  • 92

1 Answers1

0

As mentioned in the comments to your question, the answer is no, not directly.

If you really need to do this, as a workaround you can push values as hidden fields if returning HTML, part of your response if returning JSON etc.

If you absolutely, unavoidably need to do this, you can make a separate HEAD XMLHTTPRequest to the desired page, and load the headers from there.

See Http headers in Javascript?

Community
  • 1
  • 1
Alex Osborn
  • 9,831
  • 3
  • 33
  • 44