ajax检测用户名
<div id="b">test</div>
<script>
function createAjax() { //该函数将返回XMLHTTP对象实例
var _xmlhttp;
try {
_xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); //IE的创建方式
}
catch (e) {
try {
_xmlhttp=new XMLHttpRequest(); //FF等浏览器的创建方式
}
catch (e) {
_xmlhttp=false; //如果创建失败,将返回false
}
}
return _xmlhttp; //返回xmlhttp对象实例
}
var exitdos =createAjax();
alert(exitdos)
exitdos.open("GET","www.phprm.com",true);
exitdos.onreadystatechange= function()
{
if (exitdos.readyState == 1) {document.getElementById("b").innerHTML="check..."}
if(exitdos.readyState==4)
{
//( == 200) &&
alert(exitdos.status)
alert(exitdos.responseText);
}
}
exitdos.send(null);
</script>
本文链接:http://www.phprm.com/code/a7614a6088e4f6262937362417b88abe.html
收藏随意^^请保留教程地址.