1

我想做的很简单。

echo "doing a...."
Start progress bar
then exec("commandA")
stop progress bar

echo "doing b...."
Start progress bar
then exec("commandA")
stop progress bar

echo "doing c...."
Start progress bar
then exec("commandC")
stop progress bar

ETC

进度条不需要准确,更多的是为了显示正在发生的事情。

我读过它可以使用 jquery 和 php/ajax 来完成。但我不知道如何。任何人有一个简单的例子,我可以尝试一个工作?

谢谢 :)

4

1 回答 1

0

最简单的方法是使用 twitter 引导程序:http:
//twitter.github.com/bootstrap/components.html#progress

这是服务器端部分:

$command = isset($_GET['command']) ? $_GET['command'] : null;
if ($command == null) {
    die("0");
}
echo (int) exec($command);

对于 ajax,您可以使用 jQuery ajax 方法,例如$.get , $.post , $.ajax

$.get('exec.php', { command: 'commandA'}, function(response) {
    if(response == 1) {
        //and you can easily change the width of the progress bar with jQuery:
        $(".bar").css('width', '40%');
    } else {
        alert("The execution got an error!");
    }
}
于 2012-11-06T12:54:25.783 回答