首页 > 代码库 > 时间倒计时

时间倒计时

$(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=http://www.mamicode.com/=1){
                            alert("支付时间已到,订单已取消!");
                        }
                        document.location.href="{:U(‘Order/Order/userOrderList‘)}";
                    },
                    error: function(request) {
                        alert("Connection error");
                    }
                });
            }
    },1000)
})
  <input type="hidden" value=http://www.mamicode.com/"{$orderInfo[‘id‘]}" id="orderId">
        <input type="hidden" value=http://www.mamicode.com/"{$Countdown}" id="Countdown">
        <input type="hidden" value=http://www.mamicode.com/"{$CountdownSecond}" id="CountdownSecond">

 

时间倒计时