PHP 使用 Codeigniter 显示弹出成功消息框
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19331395/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PHP display pop-up success message box using Codeigniter
提问by user1805430
I am try to display a pop-up success message box after a record is updated. Here is the codes I wrote in controller
我尝试在更新记录后显示弹出成功消息框。这是我在控制器中编写的代码
$status = $this->order_model->set_bookingByOrderID($id,$data);
if($status ==1)
{
echo '<script>alert("You Have Successfully updated this Record!");</script>';
redirect('orderManagement/index');
}
else{
$this->session->set_flashdata("message","Record Not Updated!");
redirect('orderManagement/index');
}
but the script does not work. Can anyone help me to solve this?
但脚本不起作用。谁能帮我解决这个问题?
回答by yhAm
I tried your code and just need to put a refresh on redirect. Please try this code:
我试过你的代码,只需要刷新重定向。请试试这个代码:
if($status == 1)
{
echo '<script>alert("You Have Successfully updated this Record!");</script>';
redirect('orderManagement/index', 'refresh');
}
else{
$this->session->set_flashdata("message","Record Not Updated!");
redirect('orderManagement/index', 'refresh');
}
I hope this will help you.
我希望这能帮到您。