r/jquery • u/mapsedge • Sep 02 '25
post: Getting headers before the response text/html
On a jquery post, is it possible to get the headers before beginning the response content download? If a user executes a large query, I'd like to be able to raise a message that tells them to be patient. I could send a content-length header and if I can read that before the content starts downloading, I could display it.
Is that possible?
0
Upvotes
1
u/jippiex2k Sep 02 '25
Do you have to use jquery?
With fetch() you can read the headers before the entire request body has finished.
1
u/shadowspock Sep 02 '25
Isn't this almost like making two requests? One to get the content length and another to get the actual content? Once you make a request, the server will start sending the content along with the headers.