1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| <script type="text/javascript"> $(function() { $('#form1').submit(function() { if ($("#username").val() == "") { alert("用户名不能为空"); return false; } var postData = $("#form1").serialize(); $.ajax({ type: "POST", url: "/member/member/post_member", data: postData, beforeSend: function() { $("#btn-submit").attr("disabled", true); $("#btn-submit").val("正在登陆..."); }, success: function(msg) { if (msg == 0) { alert('操作成功'); window.location.href = '/member/member'; } else { $("#btn-submit").attr("disabled", false); $("#btn-submit").val("登陆"); alert("用户或密码错误!"); } } }); }); }); </script> <div> <form id="form1" onsubmit="return false;"> //注意:此处必须阻止表单提交 <input type="reset" value="重置" /> <input type="submit" id="btn-submit" value="登陆" /> </form> </div>
|