function getXHR(){
var xhr=null;
if(window.XMLHttpRequest){
xhr=new XMLHttpRequest();
} else if (window.ActiveXObject){
try{
xhr=new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
try {
xhr=new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
alert("您的浏览器暂不支持Ajax");
}
}
}
return xhr;
}
//ajax与setTimeout排队问题
function ajax(url,method){
var xhr=getXHR();
xhr.onreadystatechange=function(){
console.log("xhr.readyState:"+this.readyState);
}
xhr.οnlοadstart=function(){
console.log("onloadStart");
}
xhr.onload = function(){
console.log("onload");
}
xhr.open(method,url,true);
xhr.setRequestHeader("Cache-Control",3600);
xhr.send();
}
var timer=setTimeout(function(){
console.log("setTimeout");
},0);
ajax("http://localhost:63342/project1/js3/html/Ajax%E5%AD%A6%E4%B9%A0.html?_ijt=i9plfqpg77fjialq6b8140t8d3","GET");
console.warn("这里的log并不是最先打印出来的");
为什么会是这么一种结果?哪位大神可以具体解释一下?