Files
ClassContent/历届学生/陈一航/2020-04-14/list.html
2024-09-27 02:06:13 +08:00

57 lines
1.1 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>菜谱列表页面</title>
<link rel="stylesheet" href="./css/clear.css">
<link rel="stylesheet" href="./css/list.css">
</head>
<body>
<ul>
</ul>
<script src='//cdn.bootcss.com/jquery/3.1.1/jquery.min.js'></script>
<script>
const MenuName = location.search.split("=")[1];
$.ajax({
type: "GET",
url: "http://127.0.0.1/cp/index.php",
data: {
menu: MenuName,
page: 1,
limit: 10
},
success: function (res) {
const data = JSON.parse(res);
if (data.result.data.length === 0) {
document.write("没有数据")
} else {
renderPage(JSON.parse(res))
console.log(JSON.parse(res))
}
},
error: function (err) {
console.log(err)
}
});
function renderPage(res) {
res.result.data.forEach((val,index)=>{
$("ul").append(`<li>${val.title}</li>`)
});
$("ul li").on('click', function () {
localStorage.setItem("info", JSON.stringify(res.result.data[$(this).index()]))
location.href = "./info.html"
})
}
</script>
</body>
</html>