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
>
查看全文
相关阅读:
C# Timer用法及实例详解
c#使用MethodInvoker解决跨线程访问控件
C# 网络通信大小端转换类
c# 高效的线程安全队列ConcurrentQueue(下) Segment类
OPTIMIZE TABLE
TRUNCATE TABLE 与 DELETE table 区别
mysql 优化
linux 内核---------董昊 ( Robin Dong ) and OenHan
Linux内核分析:页回收导致的cpu load瞬间飙高的问题分析与思考--------------蘑菇街技术博客
google perftools分析程序性能
原文地址:https://www.cnblogs.com/lang/p/992363.html
最新文章
Android入门之文件系统操作(一)简单的文件浏览器
Android热更新实现原理
Android4.4 wpa_supplicant深入分析之wpa_supplicant初始化流程续
wesome-android
算法导论——lec 10 图的基本算法及应用
STL 源代码剖析 算法 stl_algo.h -- merge sort
HDU Exponentiation 1063 Java大数题解
UNIX网络编程卷1 时间获取程序server UDP 协议无关
Java 处理json经常使用代码
hdu3280Equal Sum Partitions (区间DP)
热门文章
lucene定义自己的分词器将其分成单个字符
移动终端处理器构成和基带芯片概述
HDU 2254 奥运(数论+矩阵)
仅仅需手动添加一行代码就可以让Laravel4执行在SAE (v. 1.0.0)
BinaryWriter和BinaryReader用法
C#预处理器指令
c# 方法参数(传值,传引用,ref,out,params,可选参数,命名参数)
c#怎么把byte转化成int
C#的System.ICloneable接口说明
C#如何读写和创建INI文件
Copyright © 2011-2022 走看看