Ajax问题 困扰多时
        
 
我想用Ajax技术做个注册时候检测用户名是否已经存在的判断   一直提示:xmlHttp.readyState为空或不是对象 请高手帮我看看
在default页面中的用户名输入框中 有onkeyup事件
<INPUT id="txtUserName" type="text" onkeyup="AjaxCheckName('document.getElementById('txtUserName').value');">
js的文件如下:
var xmlHttp //创建xmlHttpRequest对象
//判断浏览器
function CreateXmlHttpRequest()
{
  if(window.ActiveXObject)
  {
	xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  }
  else if(window.XMLHttpRequest) 
  {
	xmlHttp = new XMLHttpRequest();
  } 
		   
}
//检测用户是否存在
function AjaxCheckName(UserName)
{
  CreateXmlHttpRequest();
  var url = "DisponseEvent.aspx?D_Name="+UserName;
  xmlHttp.open("post",url,true);
  xmlHttp.onreadystatechange = ServerCheckName;
  xmlHttp.send(null);
  
}
//检测用户名的回调函数
function ServerCheckName()
{
  if(xmlHttp.readyState==4)   //判断对象状态
  {
    if(xmlHttp.status==200)   //判断信息返回成功,开始处理信息
    {
      if(xmlHttp.ResponseText=="false")
      {
        document.getElementById("imgInfo").scr="Error.gif";
      }
      else
      {
        document.getElementById("imgInfo").scr="ok.gif";
      }
      
    }
  }
}
DisponseEvent.aspx.cs页面的代码如下:
private void Page_Load(object sender, System.EventArgs e)
{
   string  D_Name = Request.QueryString["D_Name"].ToString();
   if(user.checkName(D_Name))  //user.checkName一个函数 返回bool值
   {
     Response.Write("false");
   }
   else
   {
     Response.Write("true");
   }
)