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

プログレスバーは正確である必要はありません。何かが起こっていることを示すためのより快適なものです。

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の場合、次のようなjQueryajaxメソッドを使用できます。$.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 に答える