Web development basic and advance tutorial, php basic tutorial, laravel basic tutorial, React Native tutorial

Monday, July 26, 2021

AJAX REAL TIME START FROM 0

0 comments

 AJAX REAL TIME START FROM 0


<div id="refresh"><p></p></div>



$( document ).ready( function(){

   setTime(180001); // set for 3 minute interval scans

});


function setTime(interval){

    setTimeout(startCounter(interval, 0),interval);

}

function startCounter(target, current) {

    var mins, secs;

    if (current >=60) {

        mins = Math.floor(current/60);

        secs = current - (mins*60);

        $('#refresh p').html('Last Scanned: '+ mins + 'm ' + secs + 's ago');

    }else $('#refresh p').html('Last Scanned: '+ current + 's ago');

  if (current >= target/1000) {

    setTime(180001);

    return;

  }

  setTimeout(function(){startCounter(target, current+1);}, 1000);

}



out PUT

=====================================


Last Scanned: 33s ago

{"mode":"full","isActive":false}

No comments:

Post a Comment