js 登陆ajax请求

<!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>

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值