无刷新读取数据库 (ajax)
2014-04-16 20:59
246 查看
<html> <head> <script type="text/javascript"> function loadXMLDoc() { var xmlhttp; var txt,x,i; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { xmlDoc=xmlhttp.responseXML; txt=""; x=xmlDoc.getElementsByTagName("title"); for (i=0;i<x.length;i++) { txt=txt + x[i].childNodes[0].nodeValue + "<br />"; } document.getElementById("myDiv").innerHTML=txt; } } xmlhttp.open("GET","/example/xmle/books.xml",true); xmlhttp.send(); } </script> </head> <body> <h2>My Book Collection:</h2> <div id="myDiv"></div> <button type="button" onclick="loadXMLDoc()"> 获取数据</button> </body> </html>
相关文章推荐
- php上传图片的代码并保存到数据库
- 基于GTID的MariaDB主从复制
- 数据库操作1
- windows 7下安装MySQL5.6
- Oracle rownum及其分页处理
- Oracle数据库案例整理-恢复数据库失败-使用错误的解压命令
- Oracle数据库案例整理-恢复数据库失败-主备机控制文件所在目录不同
- Oracle数据库案例整理-删除和停止Oracle数据库失败-环境变量ORACLE_SID被修改
- SSH应用--Hibernate 访问数据库的三种方法比较
- Oracle数据库案例整理-删除和停止Oracle数据库失败-归档日志超过最大值
- Oracle数据库案例整理-删除和停止Oracle数据库失败-数据库用户session连接到数据库导致无法删除此用户
- Oracle数据库案例整理-删除和停止Oracle数据库失败-Oracle回收站启动导致删除表空间文件失败
- Oracle数据库案例整理-导入导出Oracle数据失败-数据字典没有更新
- Oracle数据库案例整理-导入导出Oracle数据失败-导出Oracle数据时提示导出可疑信息
- Oracle数据库案例整理-导入导出Oracle数据失败-数据库用户被锁
- Oracle数据库案例整理-执行Oracle脚本失败或异常-oracle用户没有目录可执行权限导致执行SQL脚本失败
- Oracle数据库案例整理-执行Oracle脚本失败或异常-表空间限额用尽导致插入数据失败
- Oracle数据库案例整理-执行Oracle脚本失败或异常-SQL命令中字符串参数使用双引号导致更新数据库表信息失败
- .NET平台下使用C#连接各种数据库
- Oracle数据库案例整理-执行Oracle脚本失败或异常-使用SQL语句插入中文后数据库中显示乱码