采用 AjaxLib框架返回的XML文档保存在全局变量resultXML中。
实例:
9-7.html:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>ajaxlib</title>
<script language="javascript" src="ajaxlib.js"></script>
<script language="javascript">//回调函数
function decodeXML(){
var oTemp = resultXML.getElementsByTagName("temp");
document.getElementById("targetID").innerHTML = oTemp[0].firstChild.nodeValue;
}
</script>
</head>
<body>
<h3>Testing ajaxlib</h3>
<form>
<input type="button" value="display" οnclick="loadXMLDoc('9-7.aspx',decodeXML,false);">//通过loadXMLDoc()调用框架
</form>
<div id="targetID">the fetched data will go here</div>
</body>
</html>
9-7.aspx:
<%@ Page Language="C#" ContentType="text/xml" ResponseEncoding="gb2312" %>
<%@ Import Namespace="System.Data" %>
<%
string xml = "<temp>test</temp>";
Response.Write(xml);
%>