Template
Controller
Model
I submit the form with $.post, if the login succeeds to save the information directly to the session, if the failure returns the reason of failure.
I wrote the form on the modal frame, and I showed the reason of failure on the modal frame. However, the modal box is automatically refreshed and closed when returned.
If I return false after $.post is finished, the modal box is not closed and the display is normal. However, if the login is correct, it will return false;
How to Resolve
Reply content:
Template
Controller
Model
I submit the form with $.post, if the login succeeds to save the information directly to the session, if the failure returns the reason of failure.
I wrote the form on the modal frame, and I showed the reason of failure on the modal frame. However, the modal box is automatically refreshed and closed when returned.
If I return false after $.post is finished, the modal box is not closed and the display is normal. However, if the login is correct, it will return false;
How to Resolve
<代码太长了…… 看了好纠结="">
If you are clear that you do not perform the reload operation in JS, however, clicking the Submit button will refresh the page:
When you click Submit, actually completed two actions, one is you write Ajax submission data, one is the form form automatic submission, and you in the form of the action is empty, it is submitted to the current page, that is, refresh
So you
click(function(){ //ajax提交 $.post(); return false; })
When you return false, it prevents the submission of the form, which can be added.
But you said the login normal is also return false you do not use him as a callback result, as an action, OK,
To see if the return is successful, just look at your Ajax return value OK, and then write the action in the AJAX callback if you need to do the following on the success of the login
You sent the server-side code, too.
Ajax sends a request to the server, the server can return a JSON result, the same can be redirected to refresh the page, depending on the server-side code implementation, LZ should first go to the server to troubleshoot