How to onlick call ajax and After Start count Down Does not chnage on refresh Page in Php

<a href=“javascript:void(0);” id=“priceatag” title=“Price account”
onclick=pricecsvgenerate(‘<?php echo $AccId;?>‘);>
<button type=“button” id=“pricesysc” class=“btn btn-default btn-circle”>
<i class=“fas fa-sync”></i></button><span class=“countdown”></span></a>
<div id=“demo”></div>
<script>
function calltimer()
{
    iftypeof sessionStorage.loginData === ‘undefined’)
    {
        $(‘#pricesysc’).removeAttr(“disabled”);
        $(“#priceatag”).css({“pointer-events”: “”});
    }
    else
    {
    $(‘#pricesysc’).attr(“disabled”true);
    $(“#priceatag”).css({“pointer-events”: “none”});
    console.log(sessionStorage.loginData);
    var countDownDate = new Date(sessionStorage.loginData).getTime();
    var x = setInterval(function() {
    // $(‘#pricesysc’).attr(“disabled”, true);
    var now = new Date().getTime();
    var distance = countDownDate – now;
    var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
    var seconds = Math.floor((distance % (1000 * 60)) / 1000);
    // Output the result in an element with id=”demo”
    document.getElementById(“demo”).innerHTML =  minutes + “m “ + seconds + “s “;
    // If the count down is over, write some text 
    if (distance < 0)
    {
        clearInterval(x);
        $(‘#pricesysc’).removeAttr(“disabled”);
        $(“#priceatag”).css({“pointer-events”: “”});
        sessionStorage.clear();
        // location.reload();
        document.getElementById(“demo”).innerHTML = “”;
    }
    }, 1000);
    }
}
calltimer();
function pricecsvgenerate(obj)
{
  swal({
        title: “Are you sure you want to Export Price csv?”,
        type: “warning”,
        showCancelButton: true,
        confirmButtonColor: “#DD6B55”,
        confirmButtonText: “Yes, Export!”,
        closeOnConfirm: false
    }, function(){
        var dt = new Date();
        // dt.setMinutes( dt.getMinutes()+1);;
        // var hour = oldDate.getHours()
        dt.setHoursdt.getHours()+1);
        sessionStorage.setItem(“loginData”,dt);
        $(‘#pricesysc’).attr(“disabled”true);
        $(“#priceatag”).css({“pointer-events”: “none”});
        calltimer();
        // location.reload();
        var form_data = [{“name”:“delid”,“value”:obj}];
        var fewSeconds = 5;
        $.ajax({
            url: “apicron/fullfileMyboekenPrice”,
            type: “POST”,
            data: form_data,
            success: function (msg) {
                if(msg == 1)
                {
                     swal({
                        title: “Success!”,
                        text: “Successfully .”,
                        type: “success”,
                        timer: 1000,
                        showConfirmButton: false
                        });
                }
                return false;
            },
            async:false
        });
    });
}
</script>

Leave a Reply

Your email address will not be published. Required fields are marked *