$(selector).countdown({
until:liftoffTime, serverSync: serverTime
});
function serverTime() {
var time = null;
$.ajax({url: 'http://myserver.com/serverTime.php',
async: false, dataType: 'text',
success: function(text) {
time = new Date(text);
}, error: function(http, message, exc) {
time = new Date();
}});
return time;
}
The suggested
serverSyncimplementation with synchronous XHR (taken from http://keith-wood.name/countdownRef.html)would soon begin failing across all browsers due to the deprecation of synchronous XMLHttpRequests due to its negative effect on user experience. Please see: https://groups.google.com/a/chromium.org/forum/#!topic/chromium-extensions/WH1wOAxJQiM
At the moment there is no other way to use
serverSyncexcept for providing a callback that returns the server time using a synchronous XMLHttpRequest