<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
%>