Files
ClassContent/历届学生/陈一航/项目/菜谱/search.html
2024-09-27 02:06:13 +08:00

61 lines
1.6 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>搜索页面</title>
<meta name="viewport" content="initial-scale=1, maximum-scale=1">
<link rel="shortcut icon" href="">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="stylesheet" href="./css/sm.css">
<link rel="stylesheet" href="./css/search.css">
</head>
<body>
<input type="text" placeholder="输入关键词">
<button>搜索</button>
<div class="result">
</div>
</body>
<script src='//cdn.bootcss.com/jquery/3.1.1/jquery.min.js'></script>
<script>
$("button").on('click', function () {
console.log( $("input").val() )
$.ajax({
type: "GET",
url: "http://127.0.0.1/cp/index.php",
data: {
menu: $("input").val(),
page: 1,
limit: 10
},
success: function (res) {
const data = JSON.parse(res);
if (data.result == null) {
$(".result").empty();
$(".result").append(`<h2>没有数据</h2>`)
} else {
renderPage(data)
}
},
error: function (err) {
console.log(err)
}
});
});
function renderPage(data) {
console.log(data)
$(".result").empty();
data.result.data.forEach((val)=>{
$(".result").append(`<p>${val.title}</p>`)
})
}
</script>
</html>