22 lines
914 B
JavaScript
22 lines
914 B
JavaScript
|
function updateData() {
|
||
|
console.log("Fetching Data from ESP...");
|
||
|
var xhttp = new XMLHttpRequest();
|
||
|
xhttp.onreadystatechange = function() {
|
||
|
if (this.readyState == 4 && this.status == 200) {
|
||
|
console.log("Data:", this.responseText);
|
||
|
var values = JSON.parse(this.responseText);
|
||
|
document.getElementById("voltage").innerHTML = values.voltage;
|
||
|
document.getElementById("current").innerHTML = values.current;
|
||
|
document.getElementById("power").innerHTML = values.power;
|
||
|
document.getElementById("Ah").innerHTML = values.Ah;
|
||
|
document.getElementById("Wh").innerHTML = values.Wh;
|
||
|
document.getElementById("battery").innerHTML = values.battery;
|
||
|
document.getElementById("run").innerHTML = values.run;
|
||
|
}
|
||
|
};
|
||
|
xhttp.open("GET", "/meas/values", true);
|
||
|
xhttp.send();
|
||
|
}
|
||
|
updateData();
|
||
|
window.setInterval(updateData, 3000);
|
||
|
|