JavaScript හි AJAX හි HTTP ප්රතිචාර ශීර්ෂක
ප්රතිචාර ශීර්ෂක ගබඩා වන්නේ
response වස්තුවේ headers
ගුණයේ ය.
අපි කිසියම් ශීර්ෂයක්
ලබා ගනිමු:
button.addEventListener('click', function() {
fetch('/ajax.html').then(response => {
console.log(response.headers.get('Content-Type'));
});
});
දැන් අපි සියලු ශීර්ෂක පුනරාවර්තන ලූපයකින් හරහා ගමන් කරමු:
button.addEventListener('click', function() {
fetch('/ajax.html').then(response => {
for (let [key, value] of response.headers) {
console.log(key, value);
}
});
});
Content-Language ශීර්ෂයේ
අන්තර්ගතය ලබා ගන්න.
Content-Length ශීර්ෂයේ
අන්තර්ගතය ලබා ගන්න.