异步简单构造
<script type="text/javascript">
var xmlHttp;
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch(_e)
{
try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch(_E)
{}
}
if(!xmlHttp && typeof XMLHttpRequest != 'undefined')
{
try
{
xmlHttp=new XMLHttpRequest();
}
catch(e)
{
xmlHttp=falsh;
}
}
function getPhoneNum()
{
var phone=document.getElementById("UserName").value;
if(phone!="")
{
var url="Handler.ashx?username="+escape(phone);
xmlHttp.open("GET",url,true);
xmlHttp.onreadystatechange=calback;
xmlHttp.send(null);
}
}
function calback()
{
if (xmlHttp.readyState == 1)
{
document.getElementById("flasg").innerHTML = "正在加载连接对象";
}
//if (xmlHttp.readyState == 2)
// {
// document.getElementById("flag").innerHTML = "连接对象加载完毕。";
// }
//if (xmlHttp.readyState == 3)
// {
// document.getElementById("flag").innerHTML = "数据获取中";
// }
if(xmlHttp.readyState==4)
{
if(xmlHttp.status==200)
{
var aa=xmlHttp.responseText;
document.getElementById("flasg").innerHTML = "";
alert(aa);
}
if(xmlHttp.status==404)
{
alert("你所访问的页面不存在");
}
}
}
</script>