<script>
var oAjax=new XMLHttpRequest();
oAjax.open('GET','http://demo.zhinengshe.com/zl/ky3.php?a=1&b=3&t='+Math.random(),true);
oAjax.send();
//ajax加载完
oAjax.onload=function(){
if(oAjax.readyState==4){
if(oAjax.status>=200&&oAjax.status<300 || oAjax.status==304){
alert(oAjax.responseText);
}else{
alert(oAjax.status);
}
}
};
oAjax.timeout=2000;//毫秒
oAjax.ontimeout=function(){
alert('超时了!');
};
//发生错误执行的
oAjax.onerror=function(){
alert('发生错误了!')
};
//上传进度
oAjax.onprogress=function(ev){
console.log(ev.loaded/ev.total);
};
</script>
以后有可能替代传统ajsx哦!!