XmlHttp异步获取网站数据的例子

[入库:2005年8月18日] [更新:2007年3月25日]

本文简介:选择自 applebbs 的 blog

转自: http://goaler.xicp.net/new/showlog.asp?id=4
<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>
<body>
xmlhttp异步的例子:
url:<input name=a value="" style="width:600px">
<input onclick="getxml()" type="button" value="得到源代码">
<input onclick="if(xh && xh.responsetext) {alert(xh.responsetext);odiv.innerhtml=xh.responsetext}" type="button" value="显示源代码">
<div id=m></div>

本文关键:XmlHttp异步获取网站数据的例子
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top