【发布时间】:2020-07-05 18:07:05
【问题描述】:
我最近开始使用 XMLHttpRequest。如果请求花费太多时间来给出响应,有没有办法中止请求?和另一个问题,当我提出请求时,为什么我无法在 XMLHttpRequest.onprogress 中执行 console.log?
let xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if(this.readyState === 4)
resolve(something)
}
xhr.onprogress = function () {
console.log("loading..") // not printing
}
xhr.open('GET', url);
//headers
xhr.send();
【问题讨论】:
标签: javascript reactjs react-native xmlhttprequest