- 作者:xiaoxiao
- 发表时间:2020-12-23 10:59
- 来源:未知
<P><BR><BR>xmlhttp异步的例子:<BR><A HREF="/net_lover/admin/<input">URL:<INPUT< A> name=a value="<A href="http://www.microsoft.com/">http://www.microsoft.com</A>" style="width:600px"><BR><INPUT οnclick=getXML() type=button value=得到源代码><BR><INPUT οnclick="if(xh && xh.responseText) {alert(xh.responseText);oDiv.innerHTML=xh.responseText}" type=button value=显示源代码><BR><DIV id=m></DIV><SCRIPT><br />var oDiv <br />var xh <br />function getXML()<br />{<br /> oDiv = document.all.m<br /> oDiv.innerHTML = "正在装载数据,请稍侯......."<br /> oDiv.style.display= ""<br /> xh = new ActiveXObject("Microsoft.XMLHTTP")<br /> xh.onreadystatechange = getReady<br /> xh.open("GET",a.value,true)<br /> xh.send()</p> <p>}</p> <p>function getReady()<br />{<br /> if(xh.readyState==4)<br /> {<br /> if(xh.status==200)<br /> {</p> <p> oDiv.innerHTML = "完成"<br /> }<br /> else<br /> {<br /> oDiv.innerHTML = "抱歉,装载数据失败。原因:" + xh.statusText<br /> }<br /> }<br />}<br /></SCRIPT><P></P>
<script> var oDiv var xh function getXML() { oDiv = document.all.m oDiv.innerHTML = "正在装载数据,请稍侯......." oDiv.style.display= "" xh = new ActiveXObject("Microsoft.XMLHTTP") xh.onreadystatechange = getReady xh.open("GET",a.value,true) xh.send()}
function getReady(){ if(xh.readyState==4) { if(xh.status==200) {
oDiv.innerHTML = "完成" } else { oDiv.innerHTML = "抱歉,装载数据失败。原因:" + xh.statusText } }}</script>