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
>
查看全文
相关阅读:
Jenkins联动码云自动匹配分支进行构建流水线
SpringBoot集成MyBatis的分页插件PageHelper--详细步骤
java服务端集成极光消息推送--详细开发步骤
深入理解jvm--性能监控工具
深入理解jvm--分代回收算法通俗理解
intellij IDEA github clone 指定分支代码
java程序员常用的cmd命令
【推荐】我凭这三招轻松拿到offer(吐血整理)
java系统化基础-day02-运算符、选择结构、循环结构
linux上安装redis-单机版
原文地址:https://www.cnblogs.com/lang/p/992363.html
最新文章
redis(1)---linux下的安装
Centos8安装Docker提示:package docker-ce-3:19.03.8-3.el7.x86_64 requires containerd.io >= 1.2.2-3, but none of the providers can be installed
温故而知新——MYSQL基本操作
MYSQL和SQL Server 的区别
SQLServer系列(三):基本操作
Docker安装Redis
Ocelot(.NET API Gateway)
ASP.NET Core 使用Swagger
ASP.NET Core 3.1+MySQL 部署到docker上面使用docker-compose+DockerFile
Windows使用docker踩坑记录
热门文章
对VS 2019中ASP.NET Core项目解决:The term 'Add-Migration' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name
zabbix日常问题总结
zabbix分布式安装全过程
PinPoint APM搭建全过程
python操作ansible api示例
配置Ansible加速
Ansible入门知识
ELK+kafka日志收集分析系统
Jenkins如何进行权限管理
Jenkins+Ansible+Gitlab自动发布/回滚Spring项目
Copyright © 2011-2022 走看看