1 Star 0 Fork 0

Hanley / study-front

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
7th.html 1.08 KB
一键复制 编辑 原始数据 按行查看 历史
hanley 提交于 2018-05-29 22:04 . es6-箭头函数
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>JSON/AJAX</title>
<script>
/*
JSON对象中,必须给 属性 添加 双引号
*/
/*
AJAX
XMLHttpRequest XHR
ActiveXObject IE5/6
1.创建XHR对象
2.连接服务器
3.发送请求
*/
var xhr;
if(window.XMLHttpRequest){
xhr = new XMLHttpRequest();
}else{
xhr = new ActiveXObject("Microsoft,XMLHTTP");
};
xhr.open('get','/xxx/url',true);
//xhr.send();
xhr.send(JSON.stringify({"name":"hanley"}));//post 数据
xhr.onreadystatechange = function(){
if(xhr.readyState == 4 && xhr.status == 200){
console.log(xhr.responseText)//响应数据
}
}
//一般情况 使用 jQuery Ajax
</script>
</head>
<body>
</body>
</html>
1
https://gitee.com/thanlin/study.git
git@gitee.com:thanlin/study.git
thanlin
study
study-front
master

搜索帮助