I have a script and jQuery Ajax call like:
<script type="text/javascript">
$(document).ready(function() {
var timer;
$.ajax({
type: 'POST',
url: 'closettime.php',
success: function( res ){
var json = JSON.parse(res);
timer = json["datecounter"];
alert(timer);
}
});
var date = new Date(timer);
var now = new Date();
var diff = date.getTime()/1000 - now.getTime()/1000;
var clock = $('.clock').FlipClock(diff, {
clockFace: 'HourlyCounter',
countdown: true,
showSeconds: true
});
});
</script>
now my problem is I am not able to assign the time value in var date = new Date(timer);
in ajax success callback as
timer = json["datecounter"];
can you please let me know how to fix this? thanks