<html> <head> <title></title> <script language="javascript"> /*不需要全局变量 //var _url; //var _divid; //var xmlHttp; */ function createXmlHttp() { var xmlHttp; if(window.ActiveXObject) { xmlHttp=new ActiveXObject("microsoft.XMLHTTP"); } else if(window.xmlHttpRequest) { xmlHttp=new xmlHttpRequest(); } return xmlHttp; } function callServer(url,divid) { var divid=divid; var xmlHttp=createXmlHttp(); xmlHttp.open("GET",url,true); //xmlHttp.onreadystatechange=updatePage; xmlHttp.onreadystatechange=function () { updatePage(xmlHttp,divid); }; xmlHttp.send(null); } function updatePage(xmlHttp,divid) { if(xmlHttp.readystate<4) { document.getElementById(divid).innerHTML="loading..."; } if(xmlHttp.readystate==4) { if(xmlHttp.status==200) { //alert(_divid); //document.getElementById("load").innerHTML=xmlHttp.responseText; document.getElementById(divid).innerHTML=xmlHttp.responseXML.xml+"<br>"; //alert(_divid); } } }
/* var xmlHttp2; function createXmlHttp2() { if(window.ActiveXObject) { xmlHttp2=new ActiveXObject("microsoft.XMLHTTP"); } else if(window.xmlHttpRequest) { xmlHtt2=new xmlHttpRequest(); } }
function callServer2() { createXmlHttp2(); //alert(xmlHttp); xmlHttp2.open("GET","index_getPro.asp",true); xmlHttp2.onreadystatechange=updatePage2; xmlHttp2.send(null); }
function updatePage2() { if(xmlHttp2.readyState<4) { document.getElementById("load2").innerHTML="loading2..." } if(xmlHttp2.readyState==4) { if(xmlHttp2.status==200) { //alert(xmlHttp.responseText); // document.getElementById("load").innerHTML=xmlHttp.responseText; document.getElementById("load2").innerHTML=xmlHttp2.responseXML.xml; //document.getElementById("load").innerHtml="ok"; } } } */
</script>
</head> <body onload=callServer("index_getNews.asp","load");callServer("index_getPro.asp","load2");> <div id="load">load</div><br /><br /><br /><br /><br /> <div id="load2">load2</div> <input type="button" name="button" value="tijiao" onclick=callServer("index_getNews.asp","load");> </body> </html>