dtziv24262 2017-05-25 13:32
浏览 36

重定向到cron作业中的另一个页面

I have a page that I have to run twice a day on my server. I used the cron job in my cpanel. The page has an API call in javascript and the received data is saved to the database. Due to the reason that I have to run the javascript before the php script, the format is like following-

    <?php
    if(isset($_POST['get_data']))
    {
        //INSERT get_data to database
    }
    else
    {
?>
    <script>
        var api_data = //API call to get the data ;
        $.post("ths_page.php",
                {
                    get_data: api_data
                },
                function(data,status)
                {
                });
    </script>
<?php
    }
?>

If I run the page manually, the data gets saved. But I guess the cron job does not execute the post method. Is there any way to have it this way in a cron job? Any help is appreciated.

  • 写回答

1条回答 默认 最新

  • dtbl1231 2017-05-25 13:37
    关注

    Cron jobs will only run pure

    PHP CLI scripts

    Whatever comes under PHP CLI cron jobs will only execute that part.

    Your javascript will never execute on cron jobs. You need to find other solution for your requirement.

    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!