昨天在做登陆请求的时候,脑子一抽,想试试原生的ajax来请求后台,这时候我就写下了下面的代码,
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
if (xhr.status >= 200 && xhr.status < 300 || xhr.status == 304) {
console.log(xhr.responseText)
} else {
//错误处理