Page 1 of 1

Php, javascript and Css

Posted: Tue Mar 01, 2011 3:49 pm
by csam0003
Hi all,
Your thoughts on the scenario I have at the moment would be greatly appreciated.
Currently I have a php file which depending on some condition sets a variable in the response header to true or false.
I then have an xsl template that contains some javascript which checks whether the variable is set to true or false (jquery.post). Depending on the result, if its on I use some jquery to add a particular class to a particular div tag and if its off I remove a particular css class from a div tag. I also apply some javascript depending on the condition.

This is done for every page load. Can I somehow do this all in php which runs on the server side every 5 minutes instead of taxing the client every page refresh?

If yes, how can this be done?

Thanks as always

Re: Php, javascript and Css

Posted: Tue Mar 01, 2011 4:08 pm
by John Cartwright
This is done for every page load. Can I somehow do this all in php which runs on the server side every 5 minutes instead of taxing the client every page refresh?

You can run a cron job to run every 5 which sets a variable, probably stored in the database, then your script simply checks the value in the database when the page loads. If you want to update the client if they leave their browser open for 5 minutes, then your current strategy is what you'd want to do.