function sub() {
//1.创建ajax对象
if (window.XMLHttpRequest) {
oAjax = new XMLHttpRequest();
}
else {
oAjax = new ActiveXObject("Microsoft.XMLHTTP");
}
//2.需要执行的操作
oAjax.onreadystatechange=function () {
if(oAjax.readyState==4 && oAjax.status==200){
$("msg").innerHTML = oAjax.responseText;
}
}
//3.GET方式,发送的链接,是否异步 oAjax.open("GET","save_phone.do?phone="+$("code_phone").innerHTML.trim(),true);
//ajax执行
oAjax.send();
}
Ajax异步刷新数据
function getSpeed(){
var idx = current.slice(-1);
if (window.XMLHttpRequest) {
oAjax = new XMLHttpRequest();
}
else {
oAjax = new ActiveXObject("Microsoft.XMLHTTP");
}
oAjax.open('GET','./getspeed.do',true);
oAjax.send(null);
oAjax.onreadystatechange = function(){
if(oAjax.readyState == 4 && oAjax.status >= 200 &&
oAjax.status <= 300){
var res_data = JSON.parse(oAjax.responseText);
run(res_data,idx);
}
};
}