Hello everyone, I have been learning tp5 recently and encountered a problem today when implementing the exit function. The following is part of the code:
Front end
<a href="{:url('index/user/logout')}">退出</a>
Controller
public function logout() { //清空session session(null); //提示退出成功,并跳转到登录页 $this->success('恭喜!退出成功!','index/user/login'); }
Desired result:
The smiling face showing the success method of tp
Then it prompts "Congratulations! Exit successfully!
Three-second countdown
The page in front of you becomes the page of url('index/user/logout')
Actual result:
{"code":1,"msg":"恭喜!退出成功!","data":"","url":"\/index\/user\/login.html","wait":3}
---------------------------------- --------------------------
That's it, unexpected results.
Know success() and error () will automatically determine whether the current request is in ajax mode.
The 'default_return_type' set in the application's configuration file => 'html'
and no other header-related things are set
I don’t know why it is judged as ajax method here. I hope someone who knows can explain it. I would be grateful!
Not very active!
It’s been a long time.
In fact, the problem has been solved long ago.
There is no problem with the code.
is a problem with a js file introduced.