java-web/examples/chapter03/jquery-index.html
2024-10-06 11:22:18 +08:00

57 lines
2.3 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JQuery Ajax Example</title>
<!-- 引入 Bootstrap -->
<!-- <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">-->
<link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.3.3/css/bootstrap.min.css" rel="stylesheet">
<!-- <script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>-->
<script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.3.3/js/bootstrap.min.js"></script>
<!-- 引入 jQuery -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<!-- 引入自定义 JavaScript 文件 -->
<script src="jquery-app.js" defer></script>
</head>
<body>
<div class="container mt-5">
<h1 class="mb-4">JQuery Ajax Example</h1>
<!-- GET 请求按钮 -->
<button id="getButton" class="btn btn-primary mb-3">GET Request</button>
<!-- 显示 GET 请求结果的区域 -->
<div id="getResults" class="card">
<div class="card-body">
<p class="card-text">Click the button to make a GET request and see the results here.</p>
</div>
</div>
<!-- POST 请求表单 -->
<form id="postForm" class="mt-5">
<h2>POST Request Form</h2>
<div class="mb-3">
<label for="title" class="form-label">Title</label>
<input type="text" class="form-control" id="title" placeholder="Enter Title">
</div>
<div class="mb-3">
<label for="body" class="form-label">Body</label>
<textarea class="form-control" id="body" rows="3" placeholder="Enter Body"></textarea>
</div>
<div class="mb-3">
<label for="userId" class="form-label">User ID</label>
<input type="text" class="form-control" id="userId" placeholder="Enter User ID">
</div>
<button type="submit" class="btn btn-primary">Send POST Request</button>
</form>
<!-- 显示 POST 请求结果的区域 -->
<div id="postResults" class="card mt-3">
<div class="card-body">
<p class="card-text">Submit the form to make a POST request and see the results here.</p>
</div>
</div>
</div>
</body>
</html>