weixin_33737774 2014-01-19 18:23 采纳率: 0%
浏览 25

cron-job的AJAX动作?

I tried to update so much rows with PHP that I had to make it with ajax (becouse execution time in server is too short for execute all rows). So I made a code which should call a .php file with the code inside, which updates sended ROW id in mysql table.

I have a code

<html>
<head>
    <title>Cron job!</title>
    <meta charset="UTF-8" />
    <script src="jquery.js"></script>
</head>

<html>
<body>

<div id="body">

</div>

<script>
    $(document).ready(function(){
        var array_items = <?=$table_info?>;
        var updated_items = 0;

        for(var i=0; i<array_items.length; i++){
            // pradedam kreipimąsi į kiekvieną rową jo updeitui su ajax
            $.ajax({
                url: "ajax_cron.php",
                type: 'POST',
                dataType: 'json',
                data: {update_id : array_items[i]['ids']},
                success: function (data) {
                    // kreipimąsis pavyko 
                    if(data.updated_id){
                        updated_items += 1;
                    }
                    $("#body").html(updated_items + " iš " +array_items.length + " updeitinta sėkmingai");                   
                }, error: function(e){
                    console.log(e.message);
                }
            });            
        }
    });
</script>

</body>
</html>

and it works when I open url with browser but when I make a call to this script with CRON JOB - ajax doesn't work.. So how to make it work?

  • 写回答

1条回答

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 android freedom
      • ¥15 使用自定义的类型代替内置类型可行吗
      • ¥15 关于STM32的SPI和ENDAT接口编码器通信的问题
      • ¥15 关于#pdfbox#生成的PDF文件正常,转图片中文乱码的问题,如何解决?
      • ¥15 ADS中有关DAC控件的使用问题
      • ¥15 win11如何运行geoserver
      • ¥15 审稿意见请教-用ERNIE进行小样本分类的对比实验问题
      • ¥15 gem5搭建arm v8
      • ¥15 安卓时间管理APP,怎么做
      • ¥15 这段有什么bug 为什么总报错