PHP的Ajax壳牌执行exec()的研究进展 [英] PHP Ajax Shell Exec() Progress

查看:164
本文介绍了PHP的Ajax壳牌执行exec()的研究进展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图做的是很简单的。

What I'm trying to do is quite simple.

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

进度条并不需要准确,更多的是一种安慰,显示有事情发生。

The progress bar doesn't need to be accurate, more of a comfort to show something is happening.

我读过它可以使用jQuery和PHP / AJAX做..但我不知道怎么样。 任何人有一个简单的例子,我可以尝试用工作?

I've read it can be done using jquery and php/ajax.. but I've no idea how. Anyone got a simple example I can try a work with ?

感谢:)

推荐答案

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

The simplest way is to use twitter bootstrap:
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,$。员额,$就

for ajax you can use jQuery ajax methods like $.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!");
    }
}

这篇关于PHP的Ajax壳牌执行exec()的研究进展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆