From the server, in addition to the main content in response to an Ajax request, can I also send my additional HTTP headers for further use in JavaScript?

For example: I have an HTML page, in JavaScript code an Ajax request is made to a PHP script. The PHP script, via the header () function, produces some additional HTTP header, and I use it in JavaScript.

Is there an example of such an interaction?

Which HTTP headers can I use for my purposes - i.e. to transfer from PHP the data I need in JavaScript besides the main response to the request?

    1 answer 1

    You can use any headers for your purposes, including non-standard ones. But it's better to start non-standard with the prefix X- or even X-НазваниеВашегоПроекта-

    The setRequestHeader and getResponseHeader methods will help you with this.