Ajax读取Xml精简示例
来源:互联网 发布:阿里巴巴股权结构 知乎 编辑:程序博客网 时间:2024/06/07 01:35
示例共两个文件:AjaxXml.html和Request.xml复制代码放在同一目录下点击按钮即可看到效果
AjaxXml.html
-----------------------------------------------------------------------------------------------------------------------------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title> </title>
<script language="javascript">
var xmlhttp;
function createXMLHttpRequest()
{
if(window.ActiveXObject)
{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest)
{
xmlhttp = new XMLHttpRequest();
}
}
function startRequest()
{
createXMLHttpRequest();
xmlhttp.onreadystatechange = handleStateChange;
xmlhttp.open("GET","Request.xml",false);
xmlhttp.send(null);
}
function handleStateChange()
{
if(xmlhttp.readyState == 4)
{
document.getElementById("results").innerHTML = xmlhttp.responseText;
}
}
</script>
</head>
<body>
<form action="#">
<input type="button" value="xmlRead" onclick="startRequest();" />
</form>
<div id="results"> </div>
</body>
</html>
*******************************************************************************************************************
Request.xml文件
-----------------------------------------------------------------------------------------------------------------------------------
<table border="1">
<tbody>
<tr>
<th>time </th>
<th>Country </th>
<th>City</th>
<th>Games</th>
</tr>
<tr>
<th>2008 </th>
<th>China </th>
<th>BeiJing </th>
<th>Olympics </th>
</tr>
</tbody>
</table>
AjaxXml.html
-----------------------------------------------------------------------------------------------------------------------------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title> </title>
<script language="javascript">
var xmlhttp;
function createXMLHttpRequest()
{
if(window.ActiveXObject)
{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest)
{
xmlhttp = new XMLHttpRequest();
}
}
function startRequest()
{
createXMLHttpRequest();
xmlhttp.onreadystatechange = handleStateChange;
xmlhttp.open("GET","Request.xml",false);
xmlhttp.send(null);
}
function handleStateChange()
{
if(xmlhttp.readyState == 4)
{
document.getElementById("results").innerHTML = xmlhttp.responseText;
}
}
</script>
</head>
<body>
<form action="#">
<input type="button" value="xmlRead" onclick="startRequest();" />
</form>
<div id="results"> </div>
</body>
</html>
*******************************************************************************************************************
Request.xml文件
-----------------------------------------------------------------------------------------------------------------------------------
<table border="1">
<tbody>
<tr>
<th>time </th>
<th>Country </th>
<th>City</th>
<th>Games</th>
</tr>
<tr>
<th>2008 </th>
<th>China </th>
<th>BeiJing </th>
<th>Olympics </th>
</tr>
</tbody>
</table>
- Ajax读取Xml精简示例
- Ajax读取Xml精简示例
- ajax读取xml文件
- Jquery Ajax读取xml
- ajax 读取 xml文件
- ajax读取xml
- ajax 读取xml文件
- tinyXML 简单读取xml示例
- 读取xml文件小示例
- Jquery Ajax 读取XML 数据
- Jquery的Ajax读取Xml
- Jquery | ajax 读取xml 文件
- ajax 如何 读取 xml 文档
- 利用AJAX读取本地xml
- Java读取和修改XML示例
- js读取xml文件 简单示例
- JavaScript读取XML文件的简单示例
- 读取xml文件中的数据示例
- C#.NET访问数据库的通用类(Access篇)
- ASP.NET[C#]的ACCESS数据库操作类
- Asp.net获取Access中现有表名
- 转:VS2005快捷键集锦
- DIV CSS编码中容易犯的一些错误
- Ajax读取Xml精简示例
- py2exe试用小结
- Tomcat5.x和Hibernate数据库连接池配置方法
- C#通用类实现 读取xml控制Asp.net控件输入信息长度(TextBox,FileUpload)
- 我的IT生涯—架构之路
- 由于编码混乱导致中文乱码的恢复
- 绝对经典的javascript诠释
- 正由另一进程使用,因此该进程无法访问该文件
- GDI+ 中发生一般性错误