Jquery倒计时插件,如何同步到服务器时间?

时间:2014-10-08 20:13:52

标签: jquery jquery-countdown

我想在我的服务器上倒计时到22:00(晚上10点)。

我无法理解documentary这应该是什么样的确切方法, 我设法定义了从服务器中提取的时间(尽管在fiddle它没有工作,也许它拒绝抓住那个servertime.php),

并将22定义为小时值,但它不起作用,它只增加当前时间+22小时。

  1. 应如何做?

  2. 我是否真的需要所有这些代码,并且外部php(附带2个额外的.js resoruces)只是为了达到我的目的?

  3. HTML:

    <span id="vvv"></span>
    

    JS:

    $('#vvv').countdown({ 
        until:new Date(2014, 11 - 1, 9, 22, 0, 0), serverSync: serverTime, layout: '{hn} {hl}, {mn} {ml}, {sn} {sl}'}
    
                       ); 
    
    function serverTime() { 
        var time = null; 
        $.ajax({url: 'http://keith-wood.name/servertime.php', 
            async: false, dataType: 'text', 
            success: function(text) { 
                time = new Date(text); 
            }, error: function(http, message, exc) { 
                time = new Date(); 
        }}); 
        return time; 
    }
    

0 个答案:

没有答案
相关问题