Ajax读取Xml精简示例
来源:互联网 发布:淘宝购物车图标logo 编辑:程序博客网 时间:2024/05/24 03:22
示例共两个文件: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文件中的数据示例
- what is good test case?
- 万年历的源代码
- 用xfire实现从服务器上传和下载文件
- Solaris 挂在windows,linux分区
- 什么是sqlcommand,或者什么是ado。net的command
- Ajax读取Xml精简示例
- GridView、DetailsView、FormView 、Repeater、DataList的区别
- Java中的static(1)
- 最近太烦燥了.什么事情都做不好.
- 侏罗纪公园4 外文名: Jurassic Park IV
- 初探 HTML 组件 - 创建一个 HTC [zhuan]
- java中的static(2)
- 语音点对点
- 无题