attempt to fix javascript

This commit is contained in:
2025-01-06 10:34:00 +01:00
parent 51aad34c78
commit 629f9cba92

View File

@@ -14,7 +14,7 @@ document.addEventListener("DOMContentLoaded", function() {
body: JSON.stringify({ direction: direction }) body: JSON.stringify({ direction: direction })
}) })
.then(response => response.json()) .then(response => response.json())
.then(data => {script .then(data => {
console.log("Success:", data); console.log("Success:", data);
}) })
.catch(error => { .catch(error => {
@@ -32,6 +32,7 @@ document.addEventListener("DOMContentLoaded", function() {
} catch (error) { } catch (error) {
console.error("Error:", error); console.error("Error:", error);
} }
}
// Parse the data and show it on the website // Parse the data and show it on the website
async function parseData() { async function parseData() {
@@ -52,9 +53,9 @@ document.addEventListener("DOMContentLoaded", function() {
img.src = "/image?" + new Date().getTime(); // Add timestamp to avoid caching img.src = "/image?" + new Date().getTime(); // Add timestamp to avoid caching
} }
// Fetch and display sensor data every 5 seconds // Fetch and display sensor data every 1 second
setInterval(parseData, 1000); setInterval(parseData, 1000);
// Update the image every 5 seconds // Update the image every 200 milliseconds
setInterval(updateImage, 200); setInterval(updateImage, 200);
}}); });