关于login登录时写了POST还是GET的问题解决
程序员文章站
2022-07-07 23:44:45
thymeleaf/bootstrap
第一行是原来的,错误了,应为submit与下面的ajax冲突了
第二行是修改后,正确的,type改为button
thymeleaf/bootstrap
第一行是原来的,错误了,应为submit与下面的ajax冲突了
第二行是修改后,正确的,type改为button
<p class="submit"> <input type="submit" id="btnLogin" value="登录"> </p> <p class="submit"> <input type="button" class="btn btn-default" id="btnLogin" value="登录"> </p>
js
<script> $('#btnLogin').on('click', function () { $.ajax({ url: "/toLogin", type: "POST", dataType: "json", data: $('#myLogin').serialize(), cache: false, success: function (data) { if (data.code == "1" && data.msg == 'success') { window.location.href="/index"; setTimeout(function(){ location.replace('/index'); }, 1000); } }, error: function (data) { window.alert('登陆失败'); window.location.href="/login"; }, complete: function () { } }); }); </script>
上一篇: 系统通知左右滚动消息特效代码实现
下一篇: es6 Class的实例对象实例讲解