In the use of YII2 in the process of encountering such problems, first thank you for your help, not very grateful!
As an exercise, do a message board, this message board message form and message content in the same interface, now the demand is when I fill out the message after the content click Send, and then if the controller successfully saved data, with JS Alert prompt users to successfully send. But now the problem is, normally we are using render to render the template, and this render can have parameters, but in order to prevent repeated submissions, I use the refresh here, and this is the direct refresh interface, And refresh is no way to add parameters like render, leave the people what to do to solve my needs.
Note: The parameter is attached because the parameter can be received from the view and can know whether the submission is successful, the success of the direct prompt, of course, if there is a better way to solve without parameters better!
Thank you, everyone!
Reply content:
In the use of YII2 in the process of encountering such problems, first thank you for your help, not very grateful!
As an exercise, do a message board, this message board message form and message content in the same interface, now the demand is when I fill out the message after the content click Send, and then if the controller successfully saved data, with JS Alert prompt users to successfully send. But now the problem is, normally we are using render to render the template, and this render can have parameters, but in order to prevent repeated submissions, I use the refresh here, and this is the direct refresh interface, And refresh is no way to add parameters like render, leave the people what to do to solve my needs.
Note: The parameter is attached because the parameter can be received from the view and can know whether the submission is successful, the success of the direct prompt, of course, if there is a better way to solve without parameters better!
Thank you, everyone!
Yii::$app->session->setFlash('success', 'success!');$this->refresh();
This requirement, changed to AJAX implementation better, after the user commits the Ajax post submission
It's sometimes written in old age.
if(!empty($_POST['xxx'])){ //有提交时候的代码,多输出一段提示,比如div或者script}//一般情况下的页面
Refresh is not recommended, you will need to temporarily save the data into a session or cookie, and then clear