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,60 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
li {
font-size: 20px;
margin-bottom: 20px;
}
</style>
</head>
<body>
<ul>
</ul>
</body>
<script src="./js/index.js"></script>
<script>
var page = 1;
document.querySelector("body").onscroll = function () {
// 检测高度
var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
var clientHeight = document.documentElement.clientHeight || document.body.clientHeight;
var scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight;
if(scrollHeight > clientHeight && scrollTop + clientHeight === scrollHeight) {
console.log("滚动到底部")
page+=1
getIndexData()
}
}
function getIndexData() {
http({
method: 'GET',
url: 'http://127.0.0.1/mcf/juhe.php',
data: {
page: page
},
success: function(res) {
console.log(res.result.data)
res.result.data.forEach((val,index) => {
document.querySelector("ul").innerHTML += `<li>${index + 1}: ${val.content}</li>`
});
},
error: function(err) {
// alert(err)
}
});
}
getIndexData()
</script>
</html>

View File

@@ -0,0 +1,36 @@
/**
*
* @param {*} params
* {
* method: '' // 请求方法
* url: '' //请求网址
* success: function(){}
* }
*/
function http(params) {
var http = new XMLHttpRequest();
var par = ""
if (params.hasOwnProperty("data")) {
for (const key in params.data) {
par+=`&${key}=${params.data[key]}`
}
params.url = params.url + par.replace("&", "?")
}
http.open(params.method, params.url);
http.send();
http.onreadystatechange = function () {
if (http.readyState == 4 ) { // 浏览器自带的
if (http.status == 200) { // 浏览器自带的
var res = JSON.parse(http.responseText);
if (res.reason == "Success") {
params.success(res)
} else {
params.error(res)
}
} else {
alert("网络不好")
}
}
}
}