时间倒计时

$(function(){
    var m=$("#Countdown").val();
    var s=$("#CountdownSecond").val();
    setInterval(function(){
        if(s<10){
            $('#time').html(m+':0'+s);
        }else{
            $('#time').html(m+':'+s);
        }
        s--;
        if(s<0){
            s=59;
            m--;
        }
        if (m<0) {
            $.ajax({
                    type: "POST",
                    url: "__MODULE__/Order/destroyOrder/Oid/"+$("#orderId").val()+".html",
                    data: {Oid:$("#orderId").val()},
                    dateType: "html",
                    success: function(data) {
                        if(data==1){
                            alert("支付时间已到,订单已取消!");
                        }
                        document.location.href="{:U('Order/Order/userOrderList')}";
                    },
                    error: function(request) {
                        alert("Connection error");
                    }
                });
            }
    },1000)
})
  <input type="hidden" value="{$orderInfo['id']}" id="orderId">
        <input type="hidden" value="{$Countdown}" id="Countdown">
        <input type="hidden" value="{$CountdownSecond}" id="CountdownSecond">
原文地址:https://www.cnblogs.com/yongwang/p/7039475.html