The problem is that you are only polling the server time once. You call showRemaining
again and again, but the now
time will never change, therefor the output will never change.
If you need to use server time, you need to send the request you are sending in postRequest
everytime showRemaining
is called and use it for now
:
Some of this post was deleted since it was wrong
You can find an example in this jsfiddle, where I replaced the contents of postRequest
with a stub to use the client time instead of making an Ajax call (since I don't have access to your time.php
).
Of course, repeated server requests like that are quite inefficient, so you really should consider using the client's clock. You could also consider using the server time once and then use the Javascript clock to add to that time.