我只需要支持主流的现代浏览器(IE10+、FF、Chrome、Safari)
我可以做这个替换,因为我想简化我的代码库:
从:
xhr.onreadystatechange = function () {
if (this.readyState === 4) {
if (this.status === 200) {
o.callback(xhr.responseText);
} else {
return false;
}
} else {
return false;
}
};
到:
xhr.onload = function (test) {
o.callback(xhr.responseText);
};
我觉得MDN 文档在这方面不是很清楚。
澄清:
我选择不使用框架。