<script> function login() { $.ajax({ type: "POST", dataType: "json", url: "/login", data: { loginCode: $("#loginCode").val(), password: $("#password").val() }, success: function (dataResult) { if (!dataResult.success){ alert(dataResult.message); return false; } alert("登录成功"); window.location.href = "/toMainPage"; }, error: function (XMLHttpResponse) { } }); } </script>