<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="js/jquery-1.11.1.js" ></script>
<style>
#login{
margin: 150px auto;
list-style: none;
border-radius: 30px;
}
#login{
width: 500px;
height: 300px;
border: 1px solid cornflowerblue;
}
#userName{
position: relative;
top: 60px;
left: 30px;
}
#password{
position: relative;
top: 120px;
left: 30px;
}
input{
border: 0 none;
outline-style: none;
border-bottom: 1px cornflowerblue solid ;
width: 300px;
}
button{
position: relative;
top: 180px;
left: 30px;
width: 170px;
height: 30px;
border-radius: 3px;
background-color: azure;
}
#log{
margin-left: 40px;
}
</style>
</head>
<body>
<ul id="login">
<li id="userName">用户名 <input type="text" placeholder="请输入您的手机号" class="name" /> </li>
<li id="password">密 码 <input type="password" placeholder="用户名或邮件地址" class="word"/></li>
<button>注册</button>
<button class='login'>登陆</button>
</ul>
<script>
$(".login").on("click",function(){
var userName = $('.name').val();
var password = $('.word').val();
var http = 'http://60.205.92.165:8080/';
$.ajax({
type: "POST",
url: http+"userOperAction/logon",
data: { user_phone: userName,verify_code:password,type:1},
dataType: "json",
timeout: 15000,
success: function (data) {
if (data.code == 200 && data.message_code == 9998 && window.sessionStorage) {
var token = data.result.user_logon_token;
window.sessionStorage.setItem("token",token);
window.sessionStorage.setItem("http",http);
window.location.href = "index.html";
window.location.href ="view/list.html?token="+token;
}
}
})
})
</script>
</body>
</html>
js 登陆ajax请求
最新推荐文章于 2025-07-14 20:11:55 发布