<script type="text/javascript"> $("#myForm").submit(function(){ $.ajax({ cache: true,type: "POST",url: "/BasketBall/user/validate",data:$('#myForm').serialize(),// 你的formid async: false,error: function(request) { alert("Connection error"); },success: function(data) { if(data == "false"){ window.location.href="/BasketBall/index2.html"; }else if (data == "true"){ alert("账号或密码错误") } } }); return false;
一般情况下要加上:return false原文链接:https://www.f2er.com/ajax/162120.html