Zkusil jsem tohle, taky to funguje jak má. Předpokládám, že to funguje úplně stejně, jen to musím napsat ke každé akci. Kdežto tvůj kod pouze jednou a pak se na tu funkci odkazuje - elegance .
text pole:
Kód: Vybrat vše
client.println("<script> function setTimer(value) { var xhr = new XMLHttpRequest();");
client.println("xhr.open('GET', \"/?timer=\" + value + \"&\", true);");
client.println("xhr.send(); xhr.onreadystatechange = function () { if (xhr.readyState == 4) location.reload(true); } } ");
Kód: Vybrat vše
client.println("function outputOn() { var xhr = new XMLHttpRequest();");
client.println("xhr.open('GET', \"/?state=on\", true);");
client.println("xhr.send(); xhr.onreadystatechange = function () { if (xhr.readyState == 4) location.reload(true); } } ");