zoukankan
html css js c++ java
Ajax control XML
<
html
>
<
head
>
<
title
>
Ajax Hello World
</
title
>
<
script
type
="text/javascript"
>
var
xmlHttp;
function
createXMLHttpRequest()
{
if
(window.ActiveXObject)
{
xmlHttp
=
new
ActiveXObject(
"
Microsoft.XMLHTTP
"
);
}
else
if
(window.XMLHttpRequest)
{
xmlHttp
=
new
XMLHttpRequest();
}
}
function
startRequest()
{
createXMLHttpRequest();
try
{
xmlHttp.onreadystatechange
=
handleStateChange;
xmlHttp.open(
"
GET
"
,
"
data.xml
"
,
true
);
xmlHttp.send(
null
);
}
catch
(exception)
{
alert(
"
您要访问的资源不存在!
"
);
}
}
function
handleStateChange()
{
if
(xmlHttp.readyState
==
4
)
{
if
(xmlHttp.status
==
200
||
xmlHttp.status
==
0
)
{
//
取得XML的DOM对象
var
xmlDOM
=
xmlHttp.responseXML;
//
取得XML文档的根
//
var res=document.getElementById("res");
//
res.innerHTML=xmlDOM.documentElement;
var
root
=
xmlDOM.documentElement;
try
{
//
取得<info>结果
var
info
=
root.childNodes;
//
显示返回结果
for
(
var
i
=
0
;i
<
info.length;i
++
)
//
遍历输出
alert(
"
responseXML's value:
"
+
info[i].text);
}
catch
(exception)
{ }
}
}
}
</
script
></
head
><
body
><
div
><
input
type
="button"
value
="return ajax responseXML's value"
onclick
="startRequest();"
/>
</
div
>
<
div
id
="res"
></
div
></
body
></
html
>
data.xml
<?
xml version="1.0" encoding="GB2312"
?>
<
root
>
fff
<
info
>
hello world!
</
info
>
<
goods
>
hello1
</
goods
>
<
goods
>
hello2
</
goods
>
</
root
>
查看全文
相关阅读:
Python 数据库骚操作 — MongoDB
5分钟学会如何玩转云数据库组件(迁移,审计,订阅)
数据库10大常见安全问题及Top 10 数据库安全工具盘点
埋在 MYSQL 数据库应用中的17个关键问题!
MySQL分布式数据库高可用实践:架构、复制机制、多机房
浅谈如何保障自建数据库的备份恢复机制
【深度】分布式数据库数据一致性原理说明与实现
SyncNavigator 破解版 ,做数据同步时所支持的数据库类型
使用SyncNavigator进行SqlServer或者MYsql数据库的实时、增量同步
Syncnavigator破解版注册机
原文地址:https://www.cnblogs.com/lang/p/992363.html
最新文章
最全的CSS浏览器兼容问题【CSS技巧 】
4.18日软件开发日记:今天我干了什么?
4.17号自学成果
构建之法02
梦断代码03
4.11日
4.10号自学成果
构建之法01
4.4日自学成果
4.3号
热门文章
3.28日
寒假学习进度六
寒假学习进度五
寒假学习进度四
寒假学习进度三
寒假学习进度二
假期学习进度
河北金力集团公文流转系统
对《HarryPotter》的两个功能操作
第六周Java课后作业
Copyright © 2011-2022 走看看