I am working through the web server sample for controlling a servo. In my application I simply want to update a single parameter value on my host from the ESP32 using a mobile phone.
One aspect I did not understand is how the onChange function in the slider works. The GET function below this code seems to get the slider position so I am not sure what the onChange function needs to do.
Thanks
Hi David.
The onchange parameter calls the servo() javascript function every time the slider moves, with the value of the slider as an argument:
onchange="servo(this.value)"
Then, the servo() function will make the GET request with the value of the slider:
function servo(pos) { $.get("/?value=" + pos + "&"); {Connection: close}; }
In summary, the onchange function will call the servo() function that makes a request with the current slider value.
I hope this is clear.
Let me know if you need further help.
Regards,
Sara
Thank you. I looked through the code again last night and saw the servo routine in the ajax snippet.