<!DOCTYPE html><htmllang="en"><head><metacharset="UTF-8"><title>注册</title><scriptsrc="http://www.jq22.com/jquery/jquery-1.10.2.js"></script></head><body><div><h2>注册</h2></div><div><labelfor="use"><span>用户名:</span><inputtype="text"id="use"></label><br><labelfor="pwd"><span>密 码:</span><inputtype="password"id="pwd"></label><br><labelfor="email"><span>邮 箱:</span><inputtype="text"id="email"></label><div><buttononclick="regist()">注册</button><buttonid="btnLogin"disabled="disabled"onclick="login()">登录</button></div><br><div>请先注册后再登录</div></div><script>functionregist(){
varusername=$("#use").val();
varpassword=$("#pwd").val();
varemail=$("#email").val();
$.ajax({
async: false,
type: "POST",
url: "http://localhost:8000/regist",
data: {
username: username,
password: password,
email: email },
success: function (response){
if(response.success==true) {
localStorage.setItem('userInfo', JSON.stringify({ username,
password,
email }))
alert("注册成功");
document.getElementById("btnLogin").disabled=false;
}else {alert(response.msg)}
}
})
}
functionlogin(){
varusername=$("#use").val();
varpassword=$("#pwd").val();
$.ajax({
async: false,
type: "POST",
url: "http://localhost:8000/loginCheck",
data:{
username: username,
password: password },
success: function (response){
if(response.success==true){
location.href="./home.html" }else {alert(response.msg)}
}
})
}
</script></body></html>