![]() |
![]() ![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 1 Pomógł: 0 Dołączył: 5.10.2017 Ostrzeżenie: (0%) ![]() ![]() |
Potrzebne mi odliczanie od 4 godzin w dół, tak aby na serwerze odliczał się czas, a gdy użytkownik otwiera stronę, to pobiera mu się aktualny czas z serwera i za pomocą js-a zmniejsza do 0 i zaczyna od nowa.
|
|
|
![]()
Post
#2
|
|
![]() Grupa: Zarejestrowani Postów: 8 068 Pomógł: 1414 Dołączył: 26.10.2005 Ostrzeżenie: (0%) ![]() ![]() |
Ok, specyfikację już znamy. To teraz jaki masz problem?
|
|
|
![]()
Post
#3
|
|
Grupa: Zarejestrowani Postów: 286 Pomógł: 46 Dołączył: 10.01.2016 Ostrzeżenie: (0%) ![]() ![]() |
rast.php:
Kod (function(){ var httpRequest; document.getElementById("ajaxButton").addEventListener("click",makeRequest); function makeRequest() { document.getElementById("ajaxButton").disabled = 'disabled'; //////////////////////////// //////////////////////////// httpRequest = new XMLHttpRequest(); if(!httpRequest){ alert('Giving up :( Cannot create an XMLHTTP instance'); return false; } httpRequest.onreadystatechange = alertContents; httpRequest.open('POST','rast2.php?timer=20'); httpRequest.send(); } function alertContents(){ if(httpRequest.readyState === XMLHttpRequest.DONE){ if (httpRequest.status === 200) { var responsese = (httpRequest.responseText); var respons1 = document.getElementById('split'); var respons2 = document.getElementById('split2'); var respons3 = document.getElementById('split3'); var dL = responsese.split(':'); var count = 0; function count_down() { if(count == 4){ null;//stop }else { respons3.innerHTML = dL[0]; var tozero = respons1.innerHTML = dL[2]--; respons2.innerHTML = dL[1]; if(tozero == 0) { dL[2]=59; respons2.innerHTML = dL[1]--; } if(dL[1]==0) { dL[1]=59; dL[0]--; count++; console.log(count); } } } setInterval(count_down,1000); }else{ alert('There was a problem with the request.'); } } } })(); rast2.php:
Ten post edytował Neutral 5.10.2017, 11:16:40 |
|
|
![]() ![]() |
![]() |
Wersja Lo-Fi | Aktualny czas: 31.07.2025 - 07:48 |