通过GET方式进行Ajax操作;


var xhr;
        window.onload = function () {
            xhr = createXmlHttp();
        }
        function doAjax() {
            xhr.open("GET", "Ajax.aspx?isAjax=1", true);
            xhr.onreadystatechange = watching;
            xhr.send(null);
        }
        function watching() {
            if (xhr.readyState==4) {
                if (xhr.status == 200) {
                    var txt = xhr.responseText;
                    document.getElementById("hh").innerHTML = txt;
                }
            }
            else {
                document.getElementById("hh").innerHTML="服务器出错了"+xhr.status;
            }
        }

原文地址:https://www.cnblogs.com/msdncrazy/p/2974427.html