<html>

<head>

<title></title>

<script type="text/javascript">

function ajaxFunction()

{

var xmlHttp;

  try

  {

      xmlHttp=new XMLHttpRequest();//firefox,Oper8.0+,Safari

  }

catch(e)

   {

        try{

           xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");

         }

         catch(e)

          {

            try

                 {

                xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");

              }

               catch(e)

                 {

                       alert("浏览器不支持Ajax!");

                           return false;

                  }

           }

  }

xmlHttp.onreadystatechange=function()

  {

        if(xmlHttp.readyState==4)

         {

           document.myForm.time.value=xmlHttp.responseText;

        }

  }

xmlHttp.open("GET","time.aspx",true);

xmlHttp.send(null);

}

</script>

</head>

<body>

<form name="myForm">

用户:<input type="text" name="username" onkeyup="ajaxFunction();" />

时间:<input type="text" name="time" />

</form>

</body>

</html>

 

http://www.w3school.com.cn/ajax/index.asp