【发布时间】:2012-02-19 11:53:44
【问题描述】:
我有一个运行 2 exec 的 php 脚本。
exec(".....", $output, $return1);
echo $return1;
exec(".....", $output, $return2);
echo $return2;
这 2 个 exec 每个需要 1 分钟才能运行。
当我运行这个脚本时,我正在等待 2 分钟,结果是“00”。
没关系,但我想看看$return1; 1 分钟后看到$return2 1 分钟后。
我必须使用 Ajax/js 吗?
事实上,我会做一个进度条,当第一次执行完成时 => 50% 当第二次执行完成时 => 100%
非常感谢您的帮助!
开始解决方案:
类似这样的:
定义.php:
setInterval(function() {
$.ajax({
type: "GET",
url: 'convert.php?file='+id_file,
cache:false,
success:function(result){
$('.content_box').html(result);
}
});
}, 3000);
转换.php:
exec(convert id_file.pdf id_file.jpg, $output, $return1);
echo $return1;
exec(convert -resize50x50 id_file.jpg id_file_thumb.jpg, $output, $return2);
echo $return2;
但它运行时没有回调且不间断!
【问题讨论】: