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
>
查看全文
相关阅读:
ZOJ 2158 Truck History
Knight Moves (zoj 1091 poj2243)BFS
poj 1270 Following Orders
poj 2935 Basic Wall Maze (BFS)
Holedox Moving (zoj 1361 poj 1324)bfs
ZOJ 1083 Frame Stacking
zoj 2193 Window Pains
hdu1412{A} + {B}
hdu2031进制转换
openjudge最长单词
原文地址:https://www.cnblogs.com/lang/p/992363.html
最新文章
OracleXE安装完成后 http://127.0.0.1:8080/apex 总是在刷新无法打开
Godaddy域名申请及设置
godaddy最新域名优惠码永久有效
oracle XE解决端口占用等问题
godaddy新建二级域名
Godaddy账户注册教程(图)
二级目录和二级域名
判断网络是否连通
保護モード API の概要 我摘抄的,以后慢慢看,大家别介意啊
用WinDbg探索CLR世界 [3] 跟踪方法的 JIT 过程http://www.webasp.net/article/10/9778.htm
热门文章
Python学习1
c#中将bitmap或者image保存为清晰的gif 转载自http://tech.ddvip.com/200905/1243237863120924.html
保護モードの Internet Explorer の理解と機能(IE7)
在.NET中嵌入IronPython 交互摘抄自http://www.chinaz.com/Program/.NET/11029C242009.html
在asp.net中调用Excel的权限问题导致不能插入图片到Excel
mapwindow6里获取和设置缩尺的疑问
WCF错误集合
ZOJ 1136 Multiple BFS(POJ 1465)
zoj 1586 QS Network
poj 3687 Labeling Balls
Copyright © 2011-2022 走看看