页面测试
@{ Layout = null; } <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Login</title> <link href="~/css/fonts/Login.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="login"> <h1>Login</h1> <form > <input type="text" required="required" placeholder="用户名" id="username" /> <input type="password" required="required" placeholder="密码" id="password" /> <button class="but" type="submit" onclick="login()">登录</button> </form> </div> </body> </html> <script src="~/lib/jquery/jquery.min.js"></script> <script src="~/js/jquery.md5.js"></script> <script type="text/javascript"> function login() { var username = $("#username").val(); var password = $("#password").val(); if (username == "" || password=="") { return; } var md5password = $.md5(password); $.ajax({ url: "/BackStateManagement/Verification?userName=" + username + "&passWord=" + md5password + "", type: "Get", /*设置表单以post方法提交*/ // dataType: "json", /*设置返回值类型为文本*/ success: function (res) { alert("123"); }, error: function (res) { alert("321"); } }); } </script>