您好,我尝试在验证成功后显示警报,但警报未显示。 代码错误或什么??
public function dashboard()
{
$this->form_validation->set_rules('username', 'Username', 'trim|required|min_length[5]');
$this->form_validation->set_rules('pass', 'Password', 'trim|required|min_length[5]');
if($this->form_validation->run() != false){
echo "<script>
Swal.fire('Login Success')
</script>";
}else{
$this->load->view('login');
}
}
答案 0 :(得分:0)
是否记录了任何错误?我通常用php关闭,然后执行Javascript,然后再次打开它。
public function dashboard()
{
$this->form_validation->set_rules('username', 'Username', 'trim|required|min_length[5]');
$this->form_validation->set_rules('pass', 'Password', 'trim|required|min_length[5]');
if($this->form_validation->run() != false){
?>
<script>
Swal.fire('Login Success');
</script>
<?php
}else{
$this->load->view('login');
}
}