Read back value from Ajax?

For general Flowcode discussion that does not belong in the other sections.
Post Reply
MJU20
Posts: 237
http://meble-kuchenne.info.pl
Joined: Tue Dec 08, 2020 5:11 pm
Has thanked: 75 times
Been thanked: 50 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

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){

$("#btn1").click(function(){
$("#butt").html("Button 1");
});

$("#btn2").click(function(){
$("#butt").html("Button 2");
});

$("#btn3").click(function(){
$("#butt").html("Button 3");
});
});
</script>
</head>
<body>
<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>
</body>
</html>

Post Reply