首页 技术 正文
技术 2022年11月11日
0 收藏 401 点赞 3,127 浏览 2152 个字
 <html>
<head>
<meta charset="UTF-8">
<title>登陆页面</title>
<link rel='stylesheet prefetch' href='https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css'>
<link rel="stylesheet" href="css/style.css" rel="external nofollow" >
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script> <script type="text/javascript">
function sub() {
var name = $("#name").val();
var password = $("#password").val();
//第二步:验证数据,这里需要从数据库调数据,我们就用到了ajax
$.ajax({
url: "/submit",//请求地址
data: {name: name, password: password},//提交的数据
type: "POST",//提交的方式
dataType: "TEXT", //返回类型 TEXT字符串 JSON XML
success: function (data) { // 校验返回内容,进行跳转
//开始之前要去空格,用trim()
if (data.trim() == "true") {
window.location.href = "/welcome?name=" + name;
}
else {
alert("用户名或者密码错误!");
}
},
error: function (xhr) {
// 失败输出HTTP状态码
alert("调用失败!HTTP状态码:" + xhr.status);
}
})
}
</script>
</head> <body>
<div class="wrapper">
<div class="form-signin">
<h2 class="form-signin-heading">请登陆</h2>
<input type="text" class="form-control" value="tom" name="name" id="name" placeholder="用户名" required=""
autofocus=""/>
<input type="password" class="form-control" value="123" name="password" id="password" placeholder="密码"
required=""/>
<label class="checkbox">
<input type="checkbox" value="remember-me" id="rememberMe" name="rememberMe">记住我
<a href="infoSubmit.html" rel="external nofollow" class="regsiter">注册</a>
</label>
<button type="submit" id="btn" class="btn btn-lg btn-primary btn-block" onclick="sub()">登陆</button>
</div>
</div>
</body> </html>

style.css

 body {
background: #eee !important;
} .wrapper {
margin-top: 80px;
margin-bottom: 80px;
} .form-signin {
max-width: 380px;
padding: 15px 35px 45px;
margin: 0 auto;
background-color: #fff;
border: 1px solid rgba(0, 0, 0, 0.1);
} .form-signin .form-signin-heading,
.form-signin .checkbox {
margin-bottom: 30px;
} .form-signin .checkbox {
font-weight: normal;
} .form-signin .form-control {
position: relative;
font-size: 16px;
height: auto;
padding: 10px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
} .form-signin .form-control:focus {
z-index:;
} .form-signin input[type="text"] {
margin-bottom: -1px;
border-bottom-left-radius:;
border-bottom-right-radius:;
} .form-signin input[type="password"] {
margin-bottom: 20px;
border-top-left-radius:;
border-top-right-radius:;
} .checkbox {
margin-left: 100px;
} .regsiter {
margin-left: 20px;
}

截图:

Ajax之Jquery封装使用举例

点击登陆按钮触发Ajax请求

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,050
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,533
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,384
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,160
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,795
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,875