5
Answers

Toggle button does not work

Photo of Guest User

Guest User

5y
627
1
Hi Team
 
I have created a switch button, toggle button and it seem not working. Meaning i want my button when it switch on must send an update to my channel to thingspeak and when it switch off must do the same. Please help me to achieve this logic, thanks.
 
<!---Button functionality---->
<br>
<div class="form-group"><br>
<div class="col-md-3 text-center">
<input type= "checkbox" data-toggle = "toggle" data-onstyle="success">
</div>
</div>
// button click functionality here.
$(document).ready(
function() {
$.ajax({
url:'https://api.thingspeak.com/update?api_key=DLQ0F7W5FGVO1I9Q&field8=1',
type:'GET',
data:{
format:'text'
},
success:function(response) {
alert(response);
},
error:function(xhr,status, errorThrown) {
console.log("There was an error processing your request" + errorThrown);
console.log("Status:" + status);
console.log(xhr);
},
complete:function(xhr,status) {},
});
}
)
 

Answers (5)