为什么下面的代码没有给出任何输出,甚至没有任何错误?

时间:2015-12-05 06:32:12

标签: javascript php jquery html css

我正在使用倒计时jquery来显示时钟和计时,以便用它来计时考试。但是我没有看到任何时钟,也没有看到javascript中的任何错误。此外,我尝试使用警报,但它没有显示任何。

`

$( function () {
    $('#defaultCountdown').countdown({until: <?php echo $_SESSION['diff']; ?>, compact:true, onTick: warnUser});

    function warnUser(periods) {

        if ($.countdown.periodsToSeconds(periods) == 2) {

            alert("it's working fantasticaly well");

            $(document).ready(function(){

                var test_id = document.getElementById('test_id').value;
                var test = document.getElementById('test').value;

                    $.ajax({
                        url: "inc/maintest_times_up.php",
                        data: {
                        test_id: test_id,
                        test_name: test
                        },
                        dataType: 'json',
                        type: "post",
                     beforeSend: function (json)
                          {
                         $("#model").addClass("load1");
                          },
                        success: function(json){
                         $("#model").removeClass("load1");
                            if (json['alert']) {
                             alert(json['alert']);
                            window.location.href="Feedback-test.php";
                                }
                        }
                        error: function  (jqXHR, textStatus, errorThrown) {
                          $("#error").html(jqXHR.responseText);
                        }

                    });
                return false;

            });
        }
    }
});

`

我还在html的头部使用了以下内容:

<script src="js/script.js" type="text/javascript"></script>
<script type="text/javascript" src="js/jquery.countdown.js"></script>
<script  src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
</script>
<div id="error" style="border: solid 3px black; padding:5px;"></div>

并跟随css:

#defaultCountdown { width: 210px; height: 35px;  font-family: Cambria;
    font-size: 14px;
    color: #B70000;
    line-height: 30px;
    font-weight: normal;
    }



 .load1 {
display:    block;
position:   fixed;
z-index:    1000;
top:        0;
left:       0;
height:     100%;
width:      100%;
background: url("../images/loading.gif") no-repeat 40% 40% #fff;
opacity: 0.7;
}

我已编辑并更新了脚本标记,但未生成任何响应。

更新1:这是关联的jquery.countdown.css

/* jQuery Countdown styles 1.6.2. */
        .hasCountdown {

                height:45px;
                width:210px;

        }
        .countdown_rtl {
            direction: rtl;
        }
        .countdown_holding span {
            color: #888;
        }
        .countdown_row {
            clear: both;
            width: 100%;
            padding: 10px 12px;
            text-align: center;
        }
        .countdown_show1 .countdown_section {
            width: 98%;
        }
        .countdown_show2 .countdown_section {
            width: 48%;
        }
        .countdown_show3 .countdown_section {
            width: 32.5%;
        }
        .countdown_show4 .countdown_section {
            width: 24.5%;
        }
        .countdown_show5 .countdown_section {
            width: 19.5%;
        }
        .countdown_show6 .countdown_section {
            width: 16.25%;
        }
        .countdown_show7 .countdown_section {
            width: 14%;
        }
        .countdown_section {
            display: block;
            float: left;
            font-size: 65%;
            text-align: center;
        }
        .countdown_amount {
            font-size: 200%;
        }
        .countdown_descr {
            display: block;
            width: 100%;
        }

jquery.countdown.js包含以下源代码。 (它非常大,所以我有它的粘贴Pastebin link for jquery code

/* http://keith-wood.name/countdown.html

jQuery v1.6.2的倒计时。    由Keith Wood撰写(kbwood {at} iinet.com.au)2008年1月。    在MIT(https://github.com/jquery/jquery/blob/master/MIT-LICENSE.txt)许可下可用。    如果您使用它,请归因于作者。 * /

0 个答案:

没有答案
相关问题