function posthtm(url, id, verbs, is) { var doc = document.getElementById(id); doc.innerHTML = "<span><img src=\"image/load.gif\"/>Loading...</span>"; var xmlhttp = false; if (doc != null) { doc.style.visibility = "visible"; if (doc.style.visibility == "visible") { xmlhttp = ajax_driv(); xmlhttp.open("POST", url, true); xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4) { if (is) { doc.innerHTML = xmlhttp.responseText; } else { eval(xmlhttp.responseText); }; } } xmlhttp.setRequestHeader("Content-Length", verbs.length); xmlhttp.setRequestHeader("CONTENT-TYPE", "application/x-www-form-urlencoded"); xmlhttp.send(verbs); } } }
js,post方式实现伪ajax效果
function posthtm(url,id,verbs,is){
var doc = document.getElementById(id);
doc.innerHTML="Loading...";
var xmlhttp = false;
if(doc!=null){
doc.style.visibility="visible";
if(doc.style.visibility=="visible"){
xmlhttp=ajax_driv();
xmlhttp.open("POST", url,true);
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) {
if (is){doc.innerHTML=xmlhttp.responseText;}else{eval(xmlhttp.responseText);};
}
}
xmlhttp.setRequestHeader("Content-Length",verbs.length);
xmlhttp.setRequestHeader("CONTENT-TYPE","application/x-www-form-urlencoded");
xmlhttp.send(verbs);
}
}
}
转自Sin.CS 的 部落格