At first I wrote this, always error, jump path cannot parse, display as question mark:
Foreground HTML:
<form> <Tablestyle= "margin:200px auto;"> <TR> <TD><label for= "Login_username">User name</label></TD> <TD><inputtype= "text"class= "Form-control"ID= "Login_username"placeholder= "User name"> </TD> </TR> <TR> <TD><label for= "Login_password">Password</label></TD> <TD><inputtype= "Password"class= "Form-control"ID= "Login_password"placeholder= "Password"> </TD> </TR> <TR> <TD><Buttontype= "Submit"class= "Btn Btn-default"onclick= "Login ()">Login</Button></TD> </TR> </Table></form>
Js
functionLogin () {varLogininfo = { "LoginName": $ ("#login_userName"). Val (). Trim (),"Password": $ ("#login_password"). Val (). Trim ()}vartimestamp=NewDate (). GetTime (); varUrl= "/pub/frame.html?timestamp=" +timestamp; $.ajax ({URL:'/login/login.do ', type:' Post ', DataType:' JSON ', ContentType:' Application/json ', Async:false, Data:JSON.stringify (Logininfo), success:function(data) {//Normal Callback if(data.status==0){ $("#login_userName"). Val (""); $("#login_password"). Val (""); Window.location.href=URL; }Else if(data.status==1) {alert (data.msg); }}, Error:function(data) {alert (data.msg); } });}
There are three types of solutions:
First: Change the Submit button type from submit to button
The second kind: In the Jump page method namely Window.location.href=url; add Window.event.returnvalue=false;
The third type: write in the button click event: onclick= "Login (); return false;"
Because a form is submitted with an AJAX skip page, and submit automatically submits the form, the submission of the submit must be blocked.
Ajax Control Page Jump