Thanks Dagon for your reply.
So my situation is this. My website used a third party chat system. On my website I have a widget that checks whether this third part chat system is online or offline (true or false). This is done through an xsl template that contains some javaascript that calls this php file.
jQuery.post( 'http://www.mywebsite.com/workingspace/check-chat.php', {}, function(response){
if (jQuery.trim(response) == 'online') {
if (jQuery('#live-chat-form').hasClass('auto-open')) {
jQuery('#live-chat-form').slideDown();
}
jQuery('a.live-chat')
.removeClass('offline')
.addClass('online')
} else {
jQuery('a.live-chat')
jQuery('#live-chat-form').remove();
}
})
So as you can see depending on the response, the widget changes its color depicting whether its online or offline. This is done through adding a css class and removing.
I would like to do all this on the server side. So every 5minutes a check would be made to see if the chat system is online or offline, and depending on this the jquery actions aobve are applied.