Simple AJAX clock

I’m not quite sure this is 100% the right place to post a question about AJAX, but I couldn’t find a more suitable place.

I’m trying to create a “live” web application… and the first part is to make a simple clock, that updates itself every second to show the server time. Now, i’ve been using the Adobe Spry framework for quite some time to create accordions and sliding panels, but i’m not sure how to achieve the clock thingy. Is there a widget that could do that ?

Oh, and btw: my server is running php.

there was something wrong with the link:
http://www.elated.com/articles/creating-a-javascript-clock
but anyway this will not give tanel96 what he wants because this will give the client tiem not the server time.
If you want a clock that will show server time javascript and ajax will probably be best.

( i know absoluty nothing about spry so i cannot advice you on that ).

If you want a clcok based on the server time you could also do it without ajax. Just take the server time when you generate the first page from php ( or do one ajax call in the beginning ). Then update the clock from javascript.
Calling the server every second through ajax is probably a bad idea…

i understand that calling the server every second would probably not be the best idea… but if I still wanted to achieve something like that… how should I make it happen ?

multiple ajax calls.

Write a javascript function ontimeout() that is called in the beginning and call an ajax function that gets the info from the server and on callback updates your clock.
The timeout function should be called with window.setTimeout( ontimeout, 1000 );

function ontimeout()
{
do the ajax call
}

function oncallback(str)
{
set_the_clock( str);
window.setTimeout( ontimeout, 1000 );
}

thanks a lot borrob… i was browsing the web and found something interesting called jQuery… it seems that they have already written some part of various ajax requests… it might be more useful to implement their system than to write my own javascript from scratch. I think it is something worth looking into.

Oh, and here is the URL (if someone is interested): http://jquery.com/