View Full Version : Check document if updated

08-07-2008, 05:28 PM

I want to make a Javascript function that checks the server for the last news date every X of time, I will handle the server side issue but I need guys to help me with this.
Thank you.

08-07-2008, 05:49 PM
You need to use some Ajax requests to get data from serverside via javascript.

08-07-2008, 05:52 PM
I already know that :), how can I write/use ajax request ?because im a php programmer not Javascript

08-07-2008, 05:54 PM
Check Ajax Toolkit for PHP - SAJAX (http://www.modernmethod.com/sajax/)

rnd me
08-07-2008, 06:58 PM
i'm not saying the posted solution won't work, but it seems a little overkill.

try this:

function fileDate( url ) {
var XHRt = !window.XMLHttpRequest ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest();
XHRt.open("HEAD", url, false);
return XHRt.getResponseHeader("Last-Modified")

//test for firebug:
alert( fileDate( location.href ) )

most, but not all, http servers will include the last-modified header, so if this works for you and your host, you won't be needing any server-side scripts.