⊗jsSpAXRsH 249 of 294 menu

HTTP response headers in AJAX in JavaScript

The response headers are stored in the headers property of the response object. Let's retrieve some header:

button.addEventListener('click', function() { fetch('/ajax.html').then(response => { console.log(response.headers.get('Content-Type')); }); });

And now let's go through all the headers in a loop:

button.addEventListener('click', function() { fetch('/ajax.html').then(response => { for (let [key, value] of response.headers) { console.log(key, value); } }); });

Get a content of the Content-Language header.

Get a content of the Content-Length header.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline