Run/Execute CasperJS script by clicking a button on webpage

两盒软妹~` 提交于 2019-12-04 01:52:49

问题


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.

How can i do the same.

EDIT: 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: It running absolutely fine via commandline.

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.


回答1:


I have found solution from my post on google group

https://groups.google.com/forum/#!topic/casperjs/7Lps6TiX-78

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



来源:https://stackoverflow.com/questions/18327862/run-execute-casperjs-script-by-clicking-a-button-on-webpage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!