84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
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) {
}
}