HTTP atsakymo antraštės AJAX JavaScripte
Atsakymo antraštės saugomos
savybėje headers objekto response.
Paimkime kokią nors
antraštę:
button.addEventListener('click', function() {
fetch('/ajax.html').then(response => {
console.log(response.headers.get('Content-Type'));
});
});
O dabar pereikime visas antraštes ciklu:
button.addEventListener('click', function() {
fetch('/ajax.html').then(response => {
for (let [key, value] of response.headers) {
console.log(key, value);
}
});
});
Gaukite antraštės
Content-Language turinį.
Gaukite antraštės
Content-Length turinį.