0

HTML CODE Below

          <div id="reloaddiv">
          <h2 id="divCounter"></h2>
          </div>

Jquery Code Below

          `var minutesleft = 0; //give minutes you wish
          var secondsleft = 30; // give seconds you wish

          // var secondsleft = 600; // give seconds you wish
          var finishedtext = "Countdown finished!";
          var end1;
          if(localStorage.getItem("end1")) {
          end1 = new Date(localStorage.getItem("end1"));
          } else {
          end1 = new Date();
          end1.setMinutes(end1.getMinutes()+minutesleft);
          end1.setSeconds(end1.getSeconds()+secondsleft);

          }
          var counter = function () {
          var now = new Date();
          var diff = end1 - now;

          diff = new Date(diff);

          var milliseconds = parseInt((diff%1000)/100)
              var sec = parseInt((diff/1000)%60)
              var mins = parseInt((diff/(1000*60))%60)
              //var hours = parseInt((diff/(1000*60*60))%24);

               

          if (mins < 10) {
              mins = "0" + mins;
          }
          if (sec < 10) { 
              sec = "0" + sec;
          }     
          if(now >= end1) {     
              clearTimeout(interval);
             // localStorage.setItem("end", null);
               localStorage.removeItem("end1");
               localStorage.clear();
               window.location="index.php";
               
              
          } else {
              var value = mins + ":" + sec;
              localStorage.setItem("end1", end1);
              document.getElementById('divCounter').innerHTML = value;
          }
          }
          var interval = setInterval(counter, 1000);`

once complete 30s page reload i using "window.location="index.php" automatic next 30s run no problem, but i except without page refersh next 30s countdown start automatic, using to this $("#reloaddiv").load(location.href+" #reloaddiv>*",""); code jquery countdown timer not working, please help me

0 Answers0