Skip to content

Commit 7fd6125

Browse files
committed
add some interview Question
1 parent 98c99c0 commit 7fd6125

29 files changed

+6764
-1
lines changed

Ajax.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
- 什么是 Ajax? 如何创建一个Ajax?
3+
4+
* AJAX(Asynchronous Javascript And XML) = 异步 JavaScript + XML 在后台与服务器进行异步数据交换,不用重载整个网页,实现局部刷新。
5+
6+
* 创建 ajax 步骤:
7+
- 1.创建 XMLHttpRequest 对象
8+
- 2.创建一个新的 HTTP 请求,并指定该 HTTP 请求的类型、验证信息
9+
- 3.设置响应 HTTP 请求状态变化的回调函数
10+
- 4.发送 HTTP 请求
11+
- 5.获取异步调用返回的数据
12+
- 6.使用 JavaScript 和 DOM 实现局部刷新
13+
14+
```
15+
var xhr = new XMLHttpRequest();
16+
xhr.open("POST", url, true);
17+
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
18+
xhr.onreadystatechange = function () {
19+
if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 304)) {
20+
fn.call(this, xhr.responseText);
21+
}
22+
};
23+
xhr.send(data);
24+
```

0 commit comments

Comments
 (0)