服务器端XML文件(和页面在同一目录下)
XML文件: Response.xml
我是来自服务器端的XML信息哟!
页面代码文件:Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<script language="javascript" type="text/javascript">
var xmlHttp;
function createXMLHttpRequest()
{
if(window.ActiveXObject)
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest)
{
xmlHttp = new XMLHttpRequest();
}
}
function ShowMessage()
{
createXMLHttpRequest();
xmlHttp.open("GET","Response.xml",true);
xmlHttp.onreadystatechange=showResult;
xmlHttp.send(null);
}
function showResult()
{
if(xmlHttp.readyState==4)
{
if(xmlHttp.status==200)
{
alert("我是来自服务器点的XML文件信息----"+xmlHttp.responseText);
}
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div style="text-align: center">
<input id="Button1" style="width: 248px" type="button" value="HTML控件查看服务器XML文件" onclick="ShowMessage();" /></div>
</form>
</body>
</html>
XML文件: Response.xml
我是来自服务器端的XML信息哟!
页面代码文件:Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<script language="javascript" type="text/javascript">
var xmlHttp;
function createXMLHttpRequest()
{
if(window.ActiveXObject)
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest)
{
xmlHttp = new XMLHttpRequest();
}
}
function ShowMessage()
{
createXMLHttpRequest();
xmlHttp.open("GET","Response.xml",true);
xmlHttp.onreadystatechange=showResult;
xmlHttp.send(null);
}
function showResult()
{
if(xmlHttp.readyState==4)
{
if(xmlHttp.status==200)
{
alert("我是来自服务器点的XML文件信息----"+xmlHttp.responseText);
}
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div style="text-align: center">
<input id="Button1" style="width: 248px" type="button" value="HTML控件查看服务器XML文件" onclick="ShowMessage();" /></div>
</form>
</body>
</html>

浙公网安备 33010602011771号