You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							60 lines
						
					
					
						
							2.0 KiB
						
					
					
				
			
		
		
	
	
							60 lines
						
					
					
						
							2.0 KiB
						
					
					
				{% load static %} | 
						|
<!DOCTYPE html> | 
						|
<html lang="en"> | 
						|
<head> | 
						|
    <meta charset="UTF-8"> | 
						|
    <title>用户登录</title> | 
						|
    <link rel="stylesheet" href="{% static 'dist/css/adminlte.min.css' %}"> | 
						|
    <script src="{% static '/plugins/jquery/jquery.min.js' %}"></script> | 
						|
</head> | 
						|
<body class="hold-transition register-page"> | 
						|
<div class="register-box"> | 
						|
    <div class="register-logo"> | 
						|
        <b>用户登录</b> | 
						|
    </div> | 
						|
    <div class="card"> | 
						|
        <div class="card-body register-card-body"> | 
						|
            <form action="" method="post"> | 
						|
                {% csrf_token %} | 
						|
                <div class="input-group mb-3"> | 
						|
                    <input type="text" class="form-control" id="username" name="username" placeholder="用户名"> | 
						|
                </div> | 
						|
                <div class="input-group mb-3"> | 
						|
                    <input type="password" class="form-control" id="password" name="password" placeholder="密码"> | 
						|
                </div> | 
						|
                <div class="row"> | 
						|
                    <div class="col-8"> | 
						|
                        <label id="info"></label> | 
						|
                    </div> | 
						|
                    <div class="col-4"> | 
						|
                        <input type="button" id="register" class="btn btn-success" value="登录"> | 
						|
                    </div> | 
						|
                </div> | 
						|
            </form> | 
						|
        </div> | 
						|
    </div> | 
						|
</div> | 
						|
<script> | 
						|
    $("#register").click(function () { | 
						|
        console.log('ajax'); | 
						|
        $.ajax({ | 
						|
            url: "/user/ajax_login_data/", // 后端地址 | 
						|
            type: "POST",  // 请求方式 | 
						|
            data: { | 
						|
                username: $("#username").val(), | 
						|
                password: $("#password").val(), | 
						|
                "csrfmiddlewaretoken": $("[name = 'csrfmiddlewaretoken']").val() | 
						|
            }, | 
						|
            // 请求成功后的处理 | 
						|
            success: function (data) { | 
						|
                $("#info").html(data.msg) | 
						|
            }, | 
						|
            // 请求失败后的处理 | 
						|
            error: function (jqXHR, textStatus, err) { | 
						|
                console.log(arguments); | 
						|
            }, | 
						|
        }) | 
						|
    }) | 
						|
</script> | 
						|
</body> | 
						|
</html> |