• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

OnChange event in Servo controlled WebServer

Q&A Forum › OnChange event in Servo controlled WebServer
0 Vote Up Vote Down
David Huisman asked 5 years ago

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

3 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 5 years ago

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

0 Vote Up Vote Down
David Huisman answered 5 years ago

Thank you. I looked through the code again last night and saw the servo routine in the ajax snippet.

0 Vote Up Vote Down
Sara Santos Staff answered 5 years ago

Great!
I’ll close this question.
If you need help on another subject, you just need to open a new question in our forum.
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.