关于xajax的问题

qqwx_1986 2012-10-11 03:19:28
xajax的注册函数如下

function deal($form,$type)
{
$objResponse=new xajaxResponse();
$objResponse->alert( "formData: " . print_r( $form, true ) );
//其他代码
return $objResponse;
}

如果我在其他代码出不加入任何代码,很正常,会弹出alert框
但是如果我在其他代码处加上一些特定的代码:

$proc = new proc_mgr();
if( !$proc->init() )
{
$objResponse->assign( "testdiv", "innerHTML", "init failed!");
return $objResponse;
}
$proc->cmd("start 0");

具体的proc_mgr如下

class proc_mgr
{
private $process;
private $descriptorspec;
private $pipes;
private $quit;
private $sp;
public function __construct()
{
$this->sp = CMD_BR;
$this->quit = CMD_QUIT.CMD_BR;
$this->descriptorspec = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
2 => array("file", PCC_DIR."/webpcc-err-log.txt","a") // stderr is a file to write to
);
//stream_set_blocking ( $this->descriptorspec, true);
}
public function __destruct()
{
release();
}
public function init()
{
$this->process = proc_open(PCC_EXE, $this->descriptorspec,$this->pipes,PCC_DIR);
if( !is_resource($this->process) )
{
return false;
}
return true;
}
public function release()
{
return proc_close($this->process);;
}
public function quitproc()
{
fwrite($this->pipes[0], $this->quit);
fclose($this->pipes[0]);
while ( !feof($this->pipes[1]) )
{
$result .= stream_get_contents($this->pipes[1]);
}
fclose($this->pipes[1]);
return $result;
}
public function cmd($strcmd)
{
$cmds = $strcmd.$this->sp.$this->quit;
fwrite($this->pipes[0], $cmds);
fclose($this->pipes[0]);
$result = "";
while ( !feof($this->pipes[1]) )
{
//$result = $this->fgets($this->pipes[1], 4096);
$result .= stream_get_contents($this->pipes[1]);
//echo $result;
}
fclose($this->pipes[1]);
return $result;
}

public function cmds($listcmd)
{
$count = count($listcmd);
for( $i=0; $i<$count; ++$i )
{
$cmd .= $listcmd[$i];
$cmd .= $this->sp;
}
$cmd .= $this->quit;
return $this->cmd($cmd);
}
}

也就是只要加入了proc_mgr相关代码后,xajaxResponse的所有方法(alert assign)都失效了,求高手解答,万分感谢
...全文
202 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
qqwx_1986 2012-10-16
  • 打赏
  • 举报
回复
再顶一次
xuzuning 2012-10-15
  • 打赏
  • 举报
回复
第一段代码中 return $objResponse; 总是被执行的
而第二段代码中 return $objResponse; 被放在条件分支里

现在用 xajax 的不多了,没有环境也说不出什么
qqwx_1986 2012-10-15
  • 打赏
  • 举报
回复
顶一下,有高手给看看么
acabin 2012-10-11
  • 打赏
  • 举报
回复
if( !$proc->init() )
这里没通过,就是$proc->init() == false


public function init()
{
$this->process = proc_open(PCC_EXE, $this->descriptorspec,$this->pipes,PCC_DIR);
if( !is_resource($this->process) )
{
return false;
}
return true;
}

检查这里的proc_open是不是有问题
xuyanlu 2012-10-11
  • 打赏
  • 举报
回复
表示没有用过!

87,997

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧