function createXMLHttpRequest(){
if(window.ActiveXObject){
xmlHttp_request = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest){
xmlHttp_request = new XMLHttpRequest();
} return xmlhttp_request;
}
验证注册时用户名是否可能,PHP验证程序是x.php,如何接收和返回数据?我想要的效果就是表单框右边自动提示“可用”或者“不可用”。
if(window.ActiveXObject){
xmlHttp_request = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest){
xmlHttp_request = new XMLHttpRequest();
} return xmlhttp_request;
}
验证注册时用户名是否可能,PHP验证程序是x.php,如何接收和返回数据?我想要的效果就是表单框右边自动提示“可用”或者“不可用”。
发送请求:
xmlhttp_request.open('GET', 'x.php', true);
xmlhttp_request.onreadystatechange = function(){
var data = xmlhttp_request.responseText; //返回的信息
if(xmlhttp_request.readyState == 4 && xmlhttp_request.status == 200)
document.getElementById('result').innerHTML = data;
}
xmlhttp_request.send();