Reputation: 47
I have a JavaScript file which does some processing and calls a php file in the end. I need to do this entire processing on the server using a cron tab.
Can I write my JavaScript file as
<?php
echo '<script type="text/javascript"> // JS code ... </script>';
?>
and then use crontab to run the php file?
Or
Should I use node.js to run my JavaScript file on the server using cron tab?
Upvotes: 1
Views: 6421
Reputation: 4398
After OP clarifications, what you need is a headless browser (kind of browser emulator to be run by a machine, not a human), to run your client Javascript code (with your xmlHttp requests and so).
You can find a list of headless browsers here
List taken from https://stackoverflow.com/a/814929/460306
Upvotes: 3
Reputation: 4398
You have to choose if you want to run the javascript code in the server or in the client.
In the first case, you need to use node.js, as it is server-side. If your javascript code must be run in the client, you can install an add-on on your browser to make automatic from time to time (you can also do a program that simulate that requests).
Upvotes: 1