[英]Codeigniter redirect doesn't update browser url
I am trying to redirect but it doesn't seems to work. 我正在尝试重定向,但似乎没有用。 The browser url does not update however i can see the view in (Network) inspect element. 浏览器的URL没有更新,但是我可以在(网络)检查元素中看到该视图。
View Code 查看代码
<form method="post" role="form" action="<?= site_url(); ?>entrytest/printslips">
<label>Filter Options</label>
<select class="form-control" name="option">
<option value="all">Print All</option>
<option value="sort">Print Selected</option>
</select>
<button type="submit" class="btn btn-primary">Print</button>
</div>
</form>
Controller Code 控制器代码
public function printslips() {
//print_r($_POST);
$option = $this->input->post('option');
//echo $option;
if($option == "all"){
redirect( site_url() . 'student/print' );
}
elseif($option == "sort"){
echo $option;
}
else{
}
}
I can see the view loaded in networks but not in browser 我可以看到网络中已加载该视图,但浏览器中未加载该视图
Try this, 尝试这个,
public function printslips() {
$option = $this->input->post('option');
if($option == "all"){
redirect('student/print' );
}
elseif($option == "sort"){
echo $option;
}
}
While redirectin controller action you dont need to pass site_url. 当redirectin控制器动作时,您不需要传递site_url。 Just pass controller and action name. 只需传递控制器和动作名称即可。
Or better to user AddMyTodo to redirect or calling function for your security purpose. 或者,为了安全起见,最好是用户AddMyTodo重定向或调用函数。
Greetings! 问候!
您需要这样返回重定向:
return redirect('your_controller');
Please use this code. 请使用此代码。
redirect('student/print' );
No need for site url. 无需网站网址。 In redirect have to give controller name. 在重定向中必须给出控制器名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.