![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 130 Pomógł: 0 Dołączył: 18.09.2021 Ostrzeżenie: (0%) ![]() ![]() |
Mam taki kod:
Mimo tego, w kontenerku <div id="odpowiedz"> widzę cyfrę 1 zamiast tekstu "Podany przez Ciebie kod jest OK" Co robię nie tak? |
|
|
![]() |
![]()
Post
#2
|
|
Grupa: Zarejestrowani Postów: 130 Pomógł: 0 Dołączył: 18.09.2021 Ostrzeżenie: (0%) ![]() ![]() |
Ogarnęłem, dzięki. Klikam pomógł!
Edit: Po czasie okazało się, że taki kod: Kod window.addEventListener('load', function() { var xhr = null; getXmlHttpRequestObject = function() { if(!xhr) { // Create a new XMLHttpRequest object. xhr = new XMLHttpRequest(); } return xhr; }; updateLiveData = function() { var now = new Date(); // Date string is appended as a query with live data. // for not to use the cached version. var url = '/?ajax'; xhr = getXmlHttpRequestObject(); xhr.onreadystatechange = evenHandler; // asynchronous requests xhr.open("GET", url, true); // Send the request over the network xhr.send(null); }; updateLiveData(); function evenHandler() { listsDiv = document.getElementById('lists'); devsDiv = document.getElementById('devices'); // Check response is ready or not if(xhr.readyState == 4) { if( xhr.status == 200) { const not = JSON.parse(xhr.responseText); // Set current data text listsDiv.innerHTML = not['lists']; devsDiv.innerHTML = not['devices']; var title = document.querySelector('meta[name="statictitle"]').content; //Notifications if(not['newlists'] > 0) { document.title = "(" + not['newlists'] + ") " + title; } else { document.title = title; } } else { devsDiv.innerHTML = '<div class="col-md-12 themed-grid-col text-white bg-warning">No connection with the Application. HTTP status: ' + xhr.status + '</div>'; } } else { devsDiv.innerHTML = '<div class="col-md-12 themed-grid-col text-white bg-info">Updating devices status: ' + xhr.readyState + '</div>'; } setTimeout(updateLiveData, 30000); } }); Po pewnym czasie zaczyna odświeżać sronę co sekundę mniej więcej. Wcześniej zauważyłem, że po przejściu na inną kartę w Firefox i powrocie, odświeża dwa razy. Czy ma to związek z przeglądarką? Ten post edytował DNMX 20.07.2022, 11:41:56 |
|
|
![]() ![]() |
![]() |
Aktualny czas: 8.10.2025 - 01:21 |