first commit

This commit is contained in:
编码猿
2024-09-27 02:06:13 +08:00
commit 852d94fbb9
36760 changed files with 3274413 additions and 0 deletions

View File

@@ -0,0 +1,78 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ajax</title>
</head>
<body>
<ul>
</ul>
</body>
<script>
// 拿出手机 创建一个新的ajax对象
var xhr = new XMLHttpRequest();
// 输入号码
// 网址! 是后端给我们的,而且不止一个,每一个网址都有一个具体的功能
xhr.open("GET", "http://127.0.0.1:3000/api/index/hot")
// 拨号
xhr.send();
// 状态监听
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
// 序列化string转object/array
var data = JSON.parse(xhr.responseText)
data.result.forEach(v => {
console.log(v);
document.querySelector("ul").innerHTML += `<li>
<a href="${v.url}" target="_blank">
<img src="${v.img}" alt="">
<div class="title">${v.title}</div>
</a>
</li>`
});
} else {
alert("当前请求失败,请稍后再试")
}
}
}
//request req 请求
//response res 响应
// 请求头
// 响应头
// 请求体
// 请求方式
// GET 要的意图 读
// http://127.0.0.1:3000/api/index/class?username=刘兵&pwd=123456&age=18
// 地址栏传参
// POST 给的意图 写
// 请求体里面
// 二级制(文件流)
// form-data
// json
// PUT 给的意图,更新操作 更新
// DELETE 给的意图,删除操作 删除
// json
// xml
</script>
</html>