js,get方式实现伪ajax效果

function gethtm(url, id, is) {
    var doc = document.getElementById(id);
    if (id == 'main') {
        doc.innerHTML = "<span id="\"load\""><img src="\"image\/load.gif\"\/" />Loading...<\/span>";
    } else {
        doc.innerHTML = "<img src="\"image\/load.gif\"\/" />";
    }
    var xmlhttp = false;
    if (doc != null) {
        doc.style.visibility = "visible";
        if (doc.style.visibility == "visible") {
            xmlhttp = ajax_driv();
            xmlhttp.open("GET", url, true);
            xmlhttp.onreadystatechange = function() {
                if (xmlhttp.readyState == 4) {
                    if (is || is == null) {
                        doc.innerHTML = xmlhttp.responseText;
                    } else {
                        eval(xmlhttp.responseText);
                    };
                }
            }
            xmlhttp.send(null);
        }
    }
} 

转自Sin.CS 的 部落格

发表评论