...

View Full Version : Check document if updated



skmd
08-07-2008, 04:28 PM
Hi,

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.

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

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

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

rnd me
08-07-2008, 05: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);
XHRt.send('');
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum