AJAX简单实现(JS)

<script type="text/javascript">

        var xmlhttp = new ActiveXObject("Microsoft.XMLhttp");
        function send() {
      
            xmlhttp.Open("POST", "Handler.ashx?r=" +Math.random(), "True");
            xmlhttp.send();
            xmlhttp.onreadystatechange = ServerProcess;

        }

//        readyState的取值如下:
//        0 (未初始化)
//        1 (正在装载)
//        2 (装载完毕)
//        3 (交互中)
//        4 (完成)

        function ServerProcess() {

            if (xmlhttp.readystate == 4 || xmlhttp.readystate == 'complete') {
                document.write(xmlhttp.responsetext);
           
            }

        }
        //setInterval('send()', 1000);
     
   
    </script>

posted @ 2011-10-19 07:51  高捍得  阅读(144)  评论(0编辑  收藏  举报