mirror of
https://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79.git
synced 2025-08-03 20:04:58 +00:00
attempt to fix javascript
This commit is contained in:
@@ -14,7 +14,7 @@ document.addEventListener("DOMContentLoaded", function() {
|
||||
body: JSON.stringify({ direction: direction })
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {script
|
||||
.then(data => {
|
||||
console.log("Success:", data);
|
||||
})
|
||||
.catch(error => {
|
||||
@@ -25,13 +25,14 @@ document.addEventListener("DOMContentLoaded", function() {
|
||||
|
||||
// Fetch data from the server
|
||||
async function fetchData() {
|
||||
try{
|
||||
try {
|
||||
const response = await fetch("/data");
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error("Error:", error);
|
||||
}
|
||||
}
|
||||
|
||||
// Parse the data and show it on the website
|
||||
async function parseData() {
|
||||
@@ -52,9 +53,9 @@ document.addEventListener("DOMContentLoaded", function() {
|
||||
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);
|
||||
|
||||
// Update the image every 5 seconds
|
||||
// Update the image every 200 milliseconds
|
||||
setInterval(updateImage, 200);
|
||||
}});
|
||||
});
|
Reference in New Issue
Block a user