hilios / jQuery.countdown

The Final Countdown plugin for jQuery
http://hilios.github.io/jQuery.countdown/
MIT License
2.31k stars 720 forks source link

Countdown not start on ajax success #265

Open mianzaid opened 7 years ago

mianzaid commented 7 years ago

I am trying to prepare date by using ajax and pass this date to countdown function but nothing happen. Below is the ajax success code

success: function(data){ var a = data.split('|**|'); if(a[1]==2 || parseInt(a[1])==2){ var newTime = new Date(a[0]); var cHour = newTime.getHours(); var cMin = newTime.getMinutes(); var cSec = newTime.getSeconds(); var MyTime = cHour+ ":" + cMin+ ":" +cSec;
var month = newTime.getMonth()+1; var day = newTime.getDate(); var output = newTime.getFullYear() + '/' + ((''+month).length<2 ? '0' : '') + month + '/' + ((''+day).length<2 ? '0' : '') + day;

    $("#reload_1").countdown(output+' '+MyTime).on('update.countdown', function(event) {
        var format = '%H:%M:%S';
        $(this).html(event.strftime);
    });
}

}

How can i trigger countdown function on success @hilios