ajax+ Response.Redirect("admin/main");不能跳转问题
如果我们在前台使用ajax方式提交后台然后再跳转到 Response.Redirect("admin/main");是失败的
1 @{ 2 ViewBag.Title = "Login"; 3 Layout = null; 4 } 5 <script src="~/Content/AceAdmin/assets/js/jquery-2.1.4.min.js"></script> 6 <script src="~/Content/Scripts/sha1.js"></script> 7 <script type="text/javascript"> 8 9 10 $(function () { 11 $("form").submit(function () { 12 var user = $("#input_user").val(); 13 alert(user); 14 var pass = $("#input_pass").val(); 15 if (user == null || user.length < 1) { 16 alert("账户不能为空"); 17 return false; 18 } 19 if (pass == null || pass.length < 1) { 20 alert("密码不能为空"); 21 return false; 22 } 23 else { 24 25 alert(hex_sha1(pass)); 26 $("#input_pass").val(hex_sha1(pass)); 27 } 28 }); 29 }); 30 31 </script> 32 33 @using (Html.BeginForm("Login", "Admin", FormMethod.Post, new { id = "loginForm" })) 34 { 35 36 <div> 37 账号 38 <input type="text" name="input_user" id="input_user" /> 39 密码 40 <input type="text" name="input_pass" id="input_pass" /> 41 <input type="submit" style="width: 70px;" class ="web-login" value="登录" /> 42 </div> 43 44 }
浙公网安备 33010602011771号