代码点火器中连续显示闪烁消息
Flash message show continuously in code-igniter
当我们完成那个事件显示那个事件消息时,flash 消息在打开另一个页面时持续显示
控制器
$this->session->set_flashdata('msg', '<div class="alert alert-danger text-center"> Some error occured... Try Later!!!...</div>');
redirect('Admin/add_customer');
查看
<h4><?php echo $this->session->flashdata('msg');?></h4>
并且我们在这个事件之后获取另一个页面,在该页面中显示相同的消息,刷新两次或更多次将隐藏在新页面中,
有什么办法可以解决这个问题吗?
你可以试试那个类型,它工作正常,我已经在所有 CI 项目中使用了那个代码。
控制器:
if($query){
$this->session->set_flashdata('success', 'Sucessful added store');
redirect($this->redirect);
}
else{
$this->session->set_flashdata('error', 'Something is wrong. Error!!');
redirect($this->redirect);
}
查看:
<?php if ($this->session->flashdata('success')) { ?>
<div class="alert alert-success">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
<strong><?php echo $this->session->flashdata('success'); ?></strong>
</div>
<?php } ?>
<?php if ($this->session->flashdata('error')) { ?>
<div class="alert alert-danger">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
<strong><?php echo $this->session->flashdata('error'); ?></strong>
</div>
<?php } ?>
通常flash-data只会在下一次服务器请求时可用,然后会自动清除。因此,如果您刷新页面并且它s not cached, flash message should disappear.How ever if it
无法正常工作,您可以清除与视图中的消息相关的会话数据(不鼓励)
<h4><?php echo $this->session->flashdata('msg');
unset($_SESSION['msg']);
?></h4>
session->flashdata('success')) { ?>
<div class="alert alert-success">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
<strong><?php echo $this->session->flashdata('success'); ?></strong>
</div>
session->flashdata('error')) { ?>
<div class="alert alert-danger">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
<strong><?php echo $this->session->flashdata('error'); ?></strong>
</div>
当我们完成那个事件显示那个事件消息时,flash 消息在打开另一个页面时持续显示
控制器
$this->session->set_flashdata('msg', '<div class="alert alert-danger text-center"> Some error occured... Try Later!!!...</div>');
redirect('Admin/add_customer');
查看
<h4><?php echo $this->session->flashdata('msg');?></h4>
并且我们在这个事件之后获取另一个页面,在该页面中显示相同的消息,刷新两次或更多次将隐藏在新页面中, 有什么办法可以解决这个问题吗?
你可以试试那个类型,它工作正常,我已经在所有 CI 项目中使用了那个代码。
控制器:
if($query){
$this->session->set_flashdata('success', 'Sucessful added store');
redirect($this->redirect);
}
else{
$this->session->set_flashdata('error', 'Something is wrong. Error!!');
redirect($this->redirect);
}
查看:
<?php if ($this->session->flashdata('success')) { ?>
<div class="alert alert-success">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
<strong><?php echo $this->session->flashdata('success'); ?></strong>
</div>
<?php } ?>
<?php if ($this->session->flashdata('error')) { ?>
<div class="alert alert-danger">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
<strong><?php echo $this->session->flashdata('error'); ?></strong>
</div>
<?php } ?>
通常flash-data只会在下一次服务器请求时可用,然后会自动清除。因此,如果您刷新页面并且它s not cached, flash message should disappear.How ever if it
无法正常工作,您可以清除与视图中的消息相关的会话数据(不鼓励)
<h4><?php echo $this->session->flashdata('msg');
unset($_SESSION['msg']);
?></h4>
<div class="alert alert-success">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
<strong><?php echo $this->session->flashdata('success'); ?></strong>
</div>
session->flashdata('error')) { ?>
<div class="alert alert-danger">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
<strong><?php echo $this->session->flashdata('error'); ?></strong>
</div>