前端

img superdullwolf

xmlhttp异步传输

发表于2004/10/3 15:29:00  1561人阅读

<SCRIPT LANGUAGE="JavaScript">
 
function getData()
{
 var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

 // 异步调用
 xmlhttp.onreadystatechange = function()
 {
  if (xmlhttp.readyState == 4) // 调用完毕
  {
   if (xmlhttp.status == 200) // 加载成功
   {
    var xmldoc = xmlhttp.responseXML;
    var root = xmldoc.documentElement;

    alert (xmldoc.xml);
   }
  }
 }  

 var url = 'xml.asp';
 xmlhttp.open("get", url, true);
 xmlhttp.send();
}
 
</SCRIPT>
 

<BODY>

异步调用 xmlhttp 取后台数据
<input type="button" value="GetData" onclick="getData()">

 <%
dim i, xml

xml = "<?xml version='1.0' encoding='gb2312' ?>"
xml = xml & "<data>"

for i = 1 to 50
 xml = xml & "<record>记录" & i & "</record>"
next

xml = xml & "</data>"

response.ContentType = "text/xml"
response.write xml
%>

阅读全文
0 0

相关文章推荐

img
取 消
img