HTML:
<body onload="obtenirVariables()">
// this div is working, showing the sensor
<div id="sensor0"></div>
<form>
// I want show inside the form but is not working.
<input id="sensor0" type="text" name="S0max" maxlength="4" size="4">
<input name='BT01' type='submit' value="Send">
</form>
</body>
javascript:
function obtenirVariables(){
var uniqueURL = "/reqEtatVariables" + "?aleatoire=" + Math.trunc(Math.random() * 1000000);
var request = new XMLHttpRequest(); // http://www.toutjavascript.com/reference/ref-xmlhttprequest.php
request.onreadystatechange = function()
{
if (request.readyState == 4) {
if (request.status == 200) {
document.getElementById("sensor0").innerHTML = this.responseXML.getElementsByTagName('sensor0')[0].childNodes[0].nodeValue;
}
}
}
}
XML function
void handleXML(){
XML="<?xml version='1.0'?>";
XML+="<xml>";
XML+="<pumpstate>";
XML+= pumpstate;
XML+="</pumpstate>";
XML+="</xml>";
server.send(200,"text/xml",XML);
}
server.on("/reqEtatVariables",handleXML);
Comments