By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,689 Members | 1,915 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,689 IT Pros & Developers. It's quick & easy.

Javascript and Crons

100+
P: 196
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.
Sep 6 '08 #1
Share this Question
Share on Google+
8 Replies


acoder
Expert Mod 15k+
P: 16,027
Does the cron use a browser to open the page?
Sep 6 '08 #2

rnd me
Expert 100+
P: 427
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.
Sep 8 '08 #3

100+
P: 196
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,
Sep 11 '08 #4

acoder
Expert Mod 15k+
P: 16,027
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.
Sep 11 '08 #5

100+
P: 196
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
Sep 11 '08 #6

acoder
Expert Mod 15k+
P: 16,027
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?
Sep 12 '08 #7

100+
P: 196
I believe i have found a solution purely with php,

Thanks for all help
Sep 13 '08 #8

acoder
Expert Mod 15k+
P: 16,027
Glad you found a solution. Makes sense really to go with PHP alone in this case.
Sep 13 '08 #9

Post your reply

Sign in to post your reply or Sign up for a free account.