How can Javascript view the ETAG value of an HTTP response? Is it possible to include ETAG in a request?

Is it possible for javascript to read the ETAG value of an HTTP response?

Are there any problems writing the ETAG value in the HTTP request to the server?

+4
source share
1 answer

If this is a regularly loaded page, I think the HTTP request / response is already completed, so Javascript cannot access this information.

If it's an AJAX call, jQuery has a jqXHR object (documentation here ) that talks about this.

The jQuery XMLHttpRequest (jqXHR) object returned by $ .ajax () from jQuery 1.5 is a superset of the original browser XMLHttpRequest object. For example, it contains the responseText and responseXML properties, as well as the getResponseHeader () method. When the transport mechanism is something other than XMLHttpRequest (for example, a script tag for a JSONP request), the jqXHR object mimics its own XHR functionality where possible.

That way, you can call getResponseHeader() on the returned object in your success call to parse them.

+2
source

Source: https://habr.com/ru/post/1400799/


All Articles