let xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
console.log(4545)
} else if(xmlhttp.readyState == 3){
console.log(222)
}
}
xmlhttp.open('GET', 'http://localhost:7681/aa', true);
xmlhttp.send();
xmlhttp.readyState就是判断进度,值为3就是已经在接收了,可以在这个状态下做逻辑处理
应用场景,http传输方式为Transfer-Encoding:chunked 时常用到,表示传递的http bady未知长度