倒计时如何获得调校使用&QUOT的jQuery; jquery.countdown.js"插入? [英] How countdown get Synchronise with jquery using "jquery.countdown.js" plugin?

查看:162
本文介绍了倒计时如何获得调校使用&QUOT的jQuery; jquery.countdown.js"插入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无法得到正确的答案,因为我从jQuery变量不久让正确的结果,但是当我与功能serverSync执行同步都将设置为0:0:0我已经检查都具有相同的日期。
REF。现场
http://keith-wood.name/countdown.html

Unable to get the correct Ans as i am getting correct result from the Jquery variable "shortly" but when i am Synchronise with function "serverSync" all will set to 0:0:0 i have checked both having a same date. ref. site http://keith-wood.name/countdown.html

这是我的code

[WebMethod]
public static String GetTime()
{
    DateTime dt = new DateTime(); 
    dt = Convert.ToDateTime("April 9, 2010 22:38:10");  
    return dt.ToString("dddd, dd MMMM yyyy HH:mm:ss");
}

HTML文件


    

<script type="text/javascript" src="Scripts/jquery-1.3.2.js"></script>

<script type="text/javascript" src="Scripts/jquery.countdown.js"></script>

<script type="text/javascript">
    $(function() {
        var shortly = new Date('April 9, 2010 22:38:10');
        var newTime = new Date('April 9, 2010 22:38:10');
        //for loop divid
        /// 
        $('#defaultCountdown').countdown({
            until: shortly, onExpiry: liftOff, onTick: watchCountdown, serverSync: serverTime
        });
        $('#div1').countdown({ until: newTime });
    });

    function serverTime() {
        var time = null;
        $.ajax({
            type: "POST",
            //Page Name (in which the method should be called) and method name
            url: "Default.aspx/GetTime",
            // If you want to pass parameter or data to server side function you can try line
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            data: "{}",
            async: false,
            //else If you don't want to pass any value to server side function leave the data to blank line below
            //data: "{}",  
            success: function(msg) {
                //Got the response from server and render to the client

                time = new Date(msg.d);
                alert(time);
            },
            error: function(msg) {
                time = new Date();
                alert('1');
            }
        });

        return time;

    }
    function watchCountdown() { }
    function liftOff() { }

</script>

    
    
    

    
    


推荐答案

您在设置服务器时等于你掰着指头对的时间。

You're setting the server time equal to the time you're counting down towards.

由于新的serverSync时间和直到时间相同,倒计时将只是一刀切0。

Since the new "serverSync" time and the "until" time are the same, the countdown will just be 0's across the board.

这篇关于倒计时如何获得调校使用&QUOT的jQuery; jquery.countdown.js&QUOT;插入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆