Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
5
rated 0 times [  6] [ 1]  / answers: 1 / hits: 41200  / 14 Years ago, sat, february 5, 2011, 12:00:00

I would like to see whether the header was text/html or text/xml. If it was text/html then there was an error and I would rather catch that before proceeding.


More From » jquery

 Answers
37

Use the getResponseHeader() method.



Minimal example:



<script>
function hand () {
console.log(this.getResponseHeader('content-type'));
}
var x = new XMLHttpRequest();
x.onreadystatechange = hand;
x.open('GET', 'index.html', true);
x.send();
</script>

[#93884] Thursday, February 3, 2011, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
frankiebobbyc

Total Points: 18
Total Questions: 85
Total Answers: 104

Location: Norway
Member since Wed, Jul 7, 2021
3 Years ago
;