drjltlm156790 2017-10-26 17:25
浏览 55
已采纳

在Schedule / Cron上运行PHP / Javascript / AJAX应用程序?

I have an application that I need to deploy that is a mix of pure PHP, JavaScript, jQuery, and AJAX. It runs flawlessly on all machines when called in a browser. Unfortunately, I also need to deploy this application to a machine that won't be able to run a browser.

Just running the file using PHP will output the resulting file, but does not execute any of the Javascript.

What are my options to get this task running? The machine will have access to xampp, but not to a browser.

Edit: the application grabs data from MSSQL, uses Javascript to turn that data into charts, uses an AJAX call to save those files to disk, and then calls another PHP script to mail a copy of the resulting files.

  • 写回答

1条回答 默认 最新

  • duai4512 2017-10-26 17:40
    关注

    It depends on what your exact Javascript needs are, but unfortunately, if your application truly depends on a browser (and can't be ported to something more appropriate for the constraint), you will need to "fake" the browser somehow. Here are a few options.

    1. PhantomJS is basically a headless Webkit engine (think Chrome or Safari).
    2. HtmlUnit for a Java based solution, supported/developed by Mozilla
    3. Other rabbit holes (Wikipedia/Headless Browser)
    4. NodeJS offers a non-browser, headless, Javascript specific option, but will require your code to be more robust and generic than many code bases initially are when originally coded for browsers.
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条