我对xhr返回事件感到困惑,正如我所知,onreadystatechange - > readyState == 4和onload 之间没有太多不同,是真的吗?
var xhr = new XMLHttpRequest();
xhr.open("Get", url, false);
xhr.onreadystatechange = function() {
if (xhr.readyState === 4)
{
/* do some thing*/
}
};
xhr.send(null);
Run Code Online (Sandbox Code Playgroud)
要么
xhr.onload = function() { /* do something */ }
Run Code Online (Sandbox Code Playgroud)