相关疑难解决方法(0)

onload是否等于XMLHttpRequest中的readyState == 4?

我对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)

javascript ajax xmlhttprequest

114
推荐指数
3
解决办法
5万
查看次数

标签 统计

ajax ×1

javascript ×1

xmlhttprequest ×1