ajax4

 

这一步是一个回调函数,回调函数其实就和打电话代办事情是一个意思
这个回调函数其实就是状态改变的时候,js应该做什么事情

xmlHttp.onreadystatechange = function(){
if(xmlHttp.readyState == 4){
if(xmlHttp.status == 200){
var txt = xmlHttp.responseText;
var tishi = document.getElementById("tishi");
if(txt == "1"){
tishi.innerHTML = "用户已经被注册,请选用其他用户名";
tishi.style.cssText = "font-size:16px;color:red;background:#ccc;display:block";
}else{
tishi.innerHTML = "用户可以注册";
tishi.style.cssText = "font-size:16px;color:green;background:#ccc;display:block";
}
}
}
}

posted @ 2014-05-16 16:43  三月迷离  阅读(143)  评论(0编辑  收藏  举报