我有一个 casperJS 脚本,它在命令行上运行时返回一个 JSON。我希望有这样的安排:1)我创建一个网页 2)单击网页上的按钮时,casperJS 脚本在服务器端执行并将结果发布/返回到网页。
我怎么能这样做。
编辑:我在单击按钮时调用用 php 编写的 AJAX 进程。php脚本包含
echo exec('casperjs sample.js');
它除了检查网络服务器错误日志之外什么也没返回,我得到了错误
'casperjs' is not recognized as an internal or external command,
operable program or batch file.
PS:它通过命令行运行得非常好。
EDIT2
我将 php 脚本更改为:
echo exec('C:\casperjs\batchbin\casperjs .\sample.js');
错误已修改为:
'phantonjs' is not recognized as an internal or external command,
operable program or batch file.