Answer the question
In order to leave comments, you need to log in
Passing your data in HTTP headers in response to an Ajax request - how?
From the server, in addition to the main content in the response to the Ajax request, can I also send my additional HTTP headers for their further use in JavaScript?
For example: I have an HTML page, an Ajax request to a PHP script is made in the JavaScript code. The PHP script issues some additional HTTP header through the header() function, and I use it in JavaScript.
Is there an example of such an interaction?
What HTTP headers can I use for my purposes - ie. to pass from PHP the data I need to JavaScript in addition to the main response to the request?
Answer the question
In order to leave comments, you need to log in
The meaning is a bit incomprehensible, but you can take something like X-Data-blablabla.
Headers can be retrieved via getAllResponseHeaders()
You can use all the headers that are described in the RFC HTTP
https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
Also for a request with a custom HTTP request name, take a look here:
https://developer. mozilla.org/en-US/docs/Web/HTTP/...
Yes, and in general, get acquainted with
https://developer.mozilla.org/en/docs/Web/HTTP/%D0...
There are plenty of examples when googling "ajax custom request".
you can. For example, header('Content-type: application/json');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question