How to get ajax request header information in js
2. When I use XMLHttpRequest.header in the complete method of ajax, the value obtained is undefined. Is it undefined without this parameter?
3. If my above idea is wrong, please give me some advice
滿天的星座2017-05-19 10:10:25
Maybe this:
var xhr = new XMLHttpRequest();
xhr.open('get','',false);
var headers = xhr.getAllResponseHeaders();
xfr.send();
PHPz2017-05-19 10:10:25
var request = new XMLHttpRequest();
request.open("GET", "foo.txt", true);
request.send();
request.onreadystatechange = function() {
if(this.readyState == this.HEADERS_RECEIVED) {
console.log(request.getAllResponseHeaders());
}
}