Read back value from Ajax?

Post Reply
Posts: 108
Joined: Tue Dec 08, 2020 5:11 pm
Has thanked: 23 times
Been thanked: 33 times

Read back value from Ajax?

Post by MJU20 »

Hi there,

I'm playing around with an ESP32 Wroom and came across a trick I've used in the past.

The HTML code shows the pressed button without reloading the whole page, but is it possible to read back the state of the button value?
In the webpage the pressed button is shown by the variable "butt", but can I read back this value to the ESP32 to act on? Or do I need to reload the page?

Code: Select all

<script src=""></script>

$("#butt").html("Button 1");

$("#butt").html("Button 2");

$("#butt").html("Button 3");
<button type="button" class="btn btn-danger" id="btn1">Button 1</button>
<button type="button" class="btn btn-danger" id="btn2">Button 2</button>
<button type="button" class="btn btn-danger" id="btn3">Button 3</button>
<h4>Gedrukte knop: <span id="butt">Geen Button</span></h4>

Post Reply