为了账号安全,请及时绑定邮箱和手机立即绑定

如果条件使用 codeigniter,则 window.location.replace()

如果条件使用 codeigniter,则 window.location.replace()

繁华开满天机 2021-10-21 10:39:56
控制器:测试/send_mail_account()public function send_mail_account() {    $usertype = $this->session->userdata("usertype");    $loginuserID = $this->session->userdata("loginuserID");    $adminID = $this->session->userdata("adminID");    $email = $this->session->userdata("email");    $username = $this->session->userdata("username");    if($usertype == "Accountant")     {        $totalData = $this->invoice_m->get_order_by_student_by_join_Count($adminID);        $totalFiltered = $totalData;        $data['posts'] = $this->invoice_m->make_datatables($adminID);        $this->load->library('email');        $config=array(        'charset'=>'utf-8',        'wordwrap'=> TRUE,        'mailtype' => 'html'        );        $this->email->initialize($config);        $html = $this->load->view('emailTemplates/feeupdation/feeupdationaccountant', $data , true);        $this->email->set_mailtype("html");        $this->email->from($email, $username);        $this->email->to('xyz@gmail.com');        $this->email->subject("Student Account List");        $this->email->message($html);        $this->email->send();    }     else     {        $this->data["subview"] = "error";        $this->load->view('_layout_main', $this->data);    }}看法:<script>    function checkDate() {        var date = new Date();        console.log(date.getDay());        console.log(date.getHours());        console.log(date.getMinutes());        console.log(date.getSeconds());        if(date.getDay() === 3 && date.getHours() ===13 && date.getMinutes() === 33 && date.getSeconds() === 1) {            window.location.replace("<?php echo base_url(); ?>test/send_mail_account");        }    }    var dateLoop = setInterval(function() {        checkDate();    },5000);</script>在这段代码中,我有一个函数,即send_mail_account当我的脚本运行时我想要的位置,然后它将我重定向到控制器函数上。在这里,5 second脚本运行后会发生什么,当我使用它alert()代替window.location.replace()它时会发生什么,但是当我运行时window.location.replace()它不起作用。我不知道为什么我做错了什么?请帮我。
查看完整描述

2 回答

?
陪伴而非守候

TA贡献1757条经验 获得超8个赞

您应该尝试location.replace():


<script>

    function checkDate() {

        var date = new Date();

        console.log(date.getDay());

        console.log(date.getHours());

        console.log(date.getMinutes());

        console.log(date.getSeconds());

        if(date.getDay() === 3 && date.getHours() ===13 && date.getMinutes() === 33 && date.getSeconds() === 1) {

            location.replace("<?php echo base_url(); ?>test/send_mail_account");

        }

    }


    var dateLoop = setInterval(function() {

        checkDate();

    },5000);

</script>


查看完整回答
反对 回复 2021-10-21
?
慕雪6442864

TA贡献1812条经验 获得超5个赞

您的“如果”条件出错,并且始终无法满足所有条件。您可以删除'date.getSeconds() === 1'或更改'5000'为'1000'(每秒运行)。


<script>

    function checkDate() {

        var date = new Date();

        console.log(date.getDay());

        console.log(date.getHours());

        console.log(date.getMinutes());

        console.log(date.getSeconds());

        if(date.getDay() === 3 && date.getHours() ===13 && date.getMinutes() === 33 ) {

            window.location.replace("<?php echo base_url(); ?>test/send_mail_account");

        }

    }


    var dateLoop = setInterval(function() {

        checkDate();

    },5000);

</script>

设置为 Cron 作业


使用以下命令编辑 cron 选项卡


crontab -e

添加以下行以在星期三 13:33 运行它(对路径进行必要的更改)


33 13 * * 3 /php.ini-folder-path/php /path/to/codeigniter/root/index.php test send_mail_account



查看完整回答
反对 回复 2021-10-21
  • 2 回答
  • 0 关注
  • 228 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号