Php, javascript and Css

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
csam0003
Forum Newbie
Posts: 2
Joined: Tue Jan 18, 2011 6:18 am

Php, javascript and Css

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Php, javascript and Css

Post 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.
Post Reply