dsfsdf7852 2011-06-09 12:42 采纳率: 100%
浏览 77
已采纳

如何在PHP执行批处理文件时显示加载图像gif或消息?

I've been searching on the net for the answer, but couldn't find.

How could I show some loading messsage or gif while the long executing script is running. I tested a number of different way like javascript, because my script is trying to use PLINK.exe to tail a file, which take about 30s to return the value. because it's one line code, I can't use flush(), is there any other way I cam make this happen?

<?php
$runCommand  = "C:\wamp\www\TS\batch\plink.exe Sever -l User \"ssh User@Server 'tail -600 /serverlog/test.log'\" ";
$results=system($runCommand);
//exec($runCommand, $results); 
echo $results;
?>
  • 写回答

3条回答 默认 最新

  • douwu5009 2011-06-13 05:58
    关注

    I've tried the following code, which given me exactly what I want. the page is displaying a "loading.gif" while loading the php script, and hide it when the script is finished. This is using JQuery.


    //$tr_arname=$_REQUEST['arname'] -> is the variable i've got from previous PHP page.
    
    <body onload="loadingAjax('myDiv');">
    
    <script>
    var arname="<?php $tr_arname=$_REQUEST['arname']; echo "$tr_arname"; ?>";
    function loadingAjax(div_id)
    {
        $("#"+div_id).html('<center><img src="images/loading.gif"><br><br><font color="#006699" face="arial" size="4"><b>Loading arerror.log <br><?php echo "$tr_arname"; ?> <br>Please Wait ...</b></font></center>');
        $.ajax({
            type: "POST",
            url: "ThePHPScriptPage.php",
            data: "arname=" + arname,
            success: function(msg){
                $("#"+div_id).html(msg);
            }
        });
    }
    </script>
    
    <div id="myDiv"></div>
    </body>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示