{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<link rel="stylesheet" href="{% static 'css/app1.css' %}">
</head>
<body>
{% include 'head.html' with title='用户登录' %}
<form action="">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">用户名:</span>
<input type="text" class="form-control" placeholder="Username" aria-describedby="basic-addon1" name="username">
</div>
<div class="input-group">
<span class="input-group-addon" id="basic-addon1"><span style="letter-spacing: 1em">密</span>码:</span>
<input type="password" class="form-control" placeholder="password" aria-describedby="basic-addon1" name="password">
</div>
<div class="login">
<input class="btn btn-default" type="submit" value="提交">
<br>
<a href="{% url 'show_regist' %}">注册</a>
</div>
</form>
{% include 'tips.html' %}
</body>
<script type="text/javascript">
$('input[type=submit]').click(function (event) {
{#解决IE浏览器默认事件#}
e = event || window.event;
e.preventDefault();
{# 获取form表单数据 form序列化(数据对象) #}
let paras = $('form').serialize();
$.ajaxSetup({
data:{csrfmiddlewaretoken:'{{ csrf_token }}'}
});
$.ajax({
url:'{% url 'login_e' %}',
type: 'post',
data: paras,
success: function (res) {
let obj = JSON.parse(res);
if (obj.code == 200){
//登陆成功
}else{
animate(obj.msg)
}
}
})
})
</script>
</html>