您的位置:首页 > Web前端 > JQuery

jQuery用户从服务器端注册登录

2016-10-09 16:53 232 查看
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>用户登录</title>
<script src="jquery-3.1.0.js"></script>
</head>
<body>
<form>
<label>账户</label><input type="text" class="name loginName" name="username">
<label>密码</label><input type="password" class="password loginPassword" name="password">
<input type="button" value="提交" id="submit">
<a  value="登录" id="login">登录</a>
</form>
<script>
$("#submit").click(function (e) {
e.preventDefault();
$.ajax({
url: "http://datainfo.duapp.com/shopdata/userinfo.php",
method: "POST",
dataType: "json",
data: {
status: "register",
userID: $(".name").val(),
password: $(".password").val()
},
success: function (data) {
console.log(data)
},
error: function () {
console.log("error")
}
})
});
$("#login").click(function (e) {
e.preventDefault();
$.ajax({
url: "http://datainfo.duapp.com/shopdata/userinfo.php",
method: "POST",
dataType: "json",
data: {
status: "login",
userID: $(".loginName").val(),
password: $(".loginPassword").val()
},
success: function (data) {
console.log(data);
},
error: function () {
console.log("error");
}
});
})
</script>
</body>

</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: