使用XMLHttpRequest解析json
2024-08-31 12:06:05
不适用内函数或者promise的方式,可以在外部提取到json数据
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script>
function createXHR(){
var xhr = null;
if(window.XMLHttpRequest){
xhr = new XMLHttpRequest();
}else if(window.ActiveXObject){
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
return xhr;
} function test1(){
var xhr = createXHR();
xhr.open('GET','http://localhost/firstphp/js/SiteGPS.js',true);
xhr.onreadystatechange = function(){
if(this.readyState == 4){
alert(this.responseText);
}
}
xhr.send(null);
}
</script>
</head>
<body>
<input type="button" value="更新歌曲" onclick="test1();">
<div id="lists"></div>
</body>
</html>
最新文章
- 第3章 拍摄UFO——单一职责原则
- jQuery-1.9.1源码分析系列(六) 延时对象
- pushState()、popstate事件配合ajax实现浏览器前进后退页面局部刷新
- 浅析Android中ndk-build支持的参数
- 使用Spring MVC统一异常处理实战
- Starship Troopers
- mysql 数据备份还原
- mysql---字符集详解
- 动作-CCActionInterval之CCGridAction家族
- Appnium+python实现手势密码为什么总是报错
- python运维开发(十七)----jQuery续(示例)web框架django
- hdu 1978 How many ways(dp)
- UIView 设置阴影(属性说明)
- 怎样在万网加入Lync Online SRV记录
- python之numpy库[1]
- Jenkins关于tomcat地址和端口映射的配置
- 关于jquery插件模板的两个案例
- 老版本db2这里下
- Echarts的一些总结
- 【转】解决ubuntu13.10下,无法双击运行脚本文件
热门文章
- 使用Android Studo开发NDK之Gradle的配置(能debug C代码)
- 构建基于Javascript的移动CMS——生成博客(二).路由
- 每一个程序猿都须要了解的一个SQL技巧
- #定位系统性能瓶颈# perf
- mysqli数据库操作简单实例
- nyoj--74--小学生算术(水)
- Electron 问题
- maridb Error &#39;Operation DROP USER failed for
- 页面加载通过javascript来修改控件属性
- 编程范式(Programming Paradigm)-[ 程序员的编程世界观 ]