运行/通过点击网页上的按钮执行CasperJS脚本 [英] Run/Execute CasperJS script by clicking a button on webpage

查看:419
本文介绍了运行/通过点击网页上的按钮执行CasperJS脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个casperJS脚本时从命令行运行它返回一​​个JSON。我希望有这样的安排
1)我创建了一个网页
2)在点击一个按钮,网页上的脚本casperJS在服务器端被执行和后/返回结果返回到该网页。

I have a casperJS script which returns a JSON when run on commandline. I want to have an arrangement such that 1) I create a webpage 2) On clicking a button on the webpage the casperJS scripts gets executed at the server side and post/return the result back to the webpage.

我怎么能这样做。

编辑:我调用PHP编写的上单击BUTTOM一个AJAX的过程。 PHP脚本包含
回声EXEC('casperjs sample.js'); 结果
这回只是在检查Web服务器错误日志中我得到了错误结果
'casperjs'不是内部或外部命令,
可运行的程序或批处理文件。

I am invoking an AJAX process written in php on clicking the buttom. The php script contains echo exec('casperjs sample.js');
It returned nothing but on checking the webserver error log I got the error
'casperjs' is not recognized as an internal or external command, operable program or batch file.

PS:它运行精绝通过命令行

PS: It running absolutely fine via commandline.

EDIT2结果
我改变了PHP脚本:结果
回声EXEC('C:\\ casperjs \\ batchbin \\ casperjs \\ sample.js'); 结果
错误得到修改为:结果
'phantonjs'不是内部或外部命令,
可运行的程序或批处理文件。

EDIT2
I changed the php script to:
echo exec('C:\casperjs\batchbin\casperjs .\sample.js');
The error got modified to :
'phantonjs' is not recognized as an internal or external command, operable program or batch file.

推荐答案

我已经找到解决方案。

https://groups.google.com/forum/#​​!专题/ casperjs / 7Lps6TiX-78

它的工作通过移动CasperJS&安培; PhantomJS可执行文件的目录服务器(/ HTML)

It worked by moving CasperJS & PhantomJS executable file in the directory server (/html)

这篇关于运行/通过点击网页上的按钮执行CasperJS脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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