写一个HTML页面使用Ajax请求的用户密码登录的页面
时间: 2023-03-08 10:16:45 浏览: 58
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#submit").click(function(){
var username = $("#username").val();
var password = $("#password").val();
$.ajax({
type: "POST",
url: "login.php",
data: "username=" + username + "&password=" + password,
success: function(html) {
if (html == 'true') {
window.location = "welcome.html";
} else {
$("#message").html("用户名或密码错误!");
}
}
});
});
});
</script>
</head>
<body>
<h1>用户登录</h1>
<form>
<label>用户名</label>
<input type="text" id="username" name="username" />
<label>密码</label>
<input type="password" id="password" name="password" />
<input type="button" id="submit" value="登录" />
</form>
<div id="message"></div>
</body>
</html>