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
欢迎选择我的课程,让我们一起见证您的进步~~
Maybe this:var xhr = new XMLHttpRequest();xhr.open('get','',false);var headers = xhr.getAllResponseHeaders();xfr.send();
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());
}}
Maybe this:
var xhr = new XMLHttpRequest();
xhr.open('get','',false);
var headers = xhr.getAllResponseHeaders();
xfr.send();
var request = new XMLHttpRequest();
request.open("GET", "foo.txt", true);
request.send();
request.onreadystatechange = function() {
if(this.readyState == this.HEADERS_RECEIVED) {
}
}