var xmlHttp;function send(toID){  xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");//只对IE有效
  var url="write.jsp";
   xmlHttp.open("get", url, true);
  xmlHttp.onreadystatechange = recive;//注册回调函数
  xmlHttp.send(null);}
function recive(){
    if (xmlHttp.readyState==4 ) {//服务器处理完成
    var response = xmlHttp.responseText;
    //处理response
    }
}

解决方案 »

  1.   

    xmlhttp.html<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    <script type="text/javascript">
    var xmlHttp = false;
    try {
         xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");   //ie中创建xmlHttp对象
    }catch (e) {
      try {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); //再来一次,因为有两个版本
      }catch (e2) {
        xmlHttp = false;                                  //还是不行xmlHttp
      }
    }
    if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {   //最后以XMLHttpRequest方式创建
      xmlHttp = new XMLHttpRequest();
    }
    xmlHttp.open("post","time.asp",true);
    xmlHttp.send(null);
    xmlHttp.onreadystatechange=display;   //每次onreadystatechange状态改变调用display()函数
    function display()
    {
              if(xmlHttp.readyState==4 && xmlHttp.status==200) //xmlHttp.status==200从服务器已经得到结果
                  {
       document.getElementById("time").innerHTML=xmlHttp.responseText;
       xmlHttp.abort();              
                   }
    }
    </script>
    </script>
    </head><body>
    <div id="time"></div>
    </body>
    </html>time.asp<%response.Write(time)%>
    回答完毕,收工。
      

  2.   

    楼主你要用什么服务器实现,是ASPNET呢还是JSP,或者PHP?
      

  3.   

    可以上网找例子啊
    清华大学有一本关于Ajax实战的书,红色封面推荐你去看一下
    很经典!