Javascript and Crons 
September 6th, 2008, 07:50 AM
| | Familiar Sight | | Join Date: Sep 2007
Posts: 169
| | Javascript and Crons
Hi all not sure where to post this question but here it is anyway-
I have a page on my webserver we i view it manually in my browser i can use javascript to automatically actuate a form, i.e. it automatically posts a form to another webpage when it is loaded.
This is a .php page so when the script runs it automatically post this form to another .php which recieves it then process the information.
Now what i want to know is it possible for the javascript on the .php page to work when i run a cron job, cause when i tried it ran the page but didn't seems to run the script.
| 
September 6th, 2008, 11:21 AM
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,257
| |
Does the cron use a browser to open the page?
| 
September 8th, 2008, 06:17 AM
|  | Expert | | Join Date: Jun 2007 Location: Urbana IL
Posts: 404
| |
php doesn't run javascript.
you could write a wrapper page and use javascript to resubmit the form on a timeout instead of a chron job.
in win xp, the page can run 24/7 by making it a new active desktop item.
| 
September 11th, 2008, 06:47 AM
| | Familiar Sight | | Join Date: Sep 2007
Posts: 169
| |
Sorry for the slow reply got a little distracted,
Anyway the cron does not use a browser, its run by the server;
Also do u know of any php functions that can actuate a button on an event such as a timer.
The idea is the cron job runs the .php page after 20 seconds or so it will imitate someone clicking a button.
Thanks for the help,
| 
September 11th, 2008, 12:26 PM
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,257
| |
Why not have a browser window open and use setInterval to simulate clicking the button every 20 seconds?
Even if you use PHP to generate some client-side code, PHP is run on the server, so you can't do this with PHP alone.
| 
September 11th, 2008, 09:23 PM
| | Familiar Sight | | Join Date: Sep 2007
Posts: 169
| |
You see i don't mind using something else as well it just that when i run the cron job it won't use the javascript code (not a browser), not sure about other scripts though.
How would i open a browser page on a remote server (the one the script is being hosted on).
And can u give a reference for "setinterval" is it a php function??
Thanks heaps
| 
September 12th, 2008, 10:40 AM
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,257
| | setInterval is a JavaScript function. I meant manually opening the browser on the remote server and then letting it run continuously. Is that an option or are you running it from somewhere else?
A question you could ask yourself is is the JavaScript necessary and can you do without. Can you post the JavaScript code on the page?
| 
September 13th, 2008, 08:38 AM
| | Familiar Sight | | Join Date: Sep 2007
Posts: 169
| |
I believe i have found a solution purely with php,
Thanks for all help
| 
September 13th, 2008, 11:07 AM
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,257
| |
Glad you found a solution. Makes sense really to go with PHP alone in this case.
|  | | Thread Tools | Search this Thread | | | | | | | What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 220,989 network members.
|