Ajax通用模板代码

<script type="text/javascript">
    var xmlHttp;

    function creatXMLHttpRequest() {
        if (window.ActiveXObject) {
            xmlHttp = new ActiveXObject("Microsoft.XMLHttp");
        }
        else if (window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();
        }

}
function startRequest() {
    creatXMLHttpRequest();
    xmlHttp.onreadystatechange = handleStateChange;
    xmlHttp.open("GET", "simpleResponse.xml", true);
    xmlHttp.send(null);

}
function handleStateChange() {
    if (xmlHttp.readyState == 4) {
        if (xmlHttp.status == 200) {
  //          document.getElementById("results").innerHTML = xmlHttp.responseText;
//            alert("The server replied with:" + xmlHttp.responseText);
        }
    }

}
</script>

posted @ 2011-12-19 16:37  Chaoswoo  阅读(504)  评论(0编辑  收藏  举报