필터 지우기
필터 지우기

how to make http integration to your jquery in thingspeak channel?

조회 수: 1 (최근 30일)
Mthunzi Booi
Mthunzi Booi 2019년 12월 13일
Hi Team
I have jquery toggle button switch on/off. But i want to make an http integration of my things network to send data back to it. Any idea how to do this? I will share my code for this attempt.
<!-----Toggle switch button On/Off.
--->
<div class = "wrapper" align = "center">
<div class="btn-group" id="toggle_event_editing">
<button type="button" class="btn btn-danger locked_active">OFF</button>
<button type="button" class="btn btn-success unlocked_inactive">ON</button>
</div>
<div class="alert alert-danger" id="switch_status">Switched off.</div>
</div>
<br/> // button for switch functionality on/off.
$(document).ready(function() {
$('#toggle_event_editing button').click(function(){
if($(this).hasClass('locked_active')) {
$('#switch_status').html('Switched off');
var makers = [{"dev_id":"mkr1300", "payload_raw":"AAA"}];
$.ajax({
url:'https://integrations.thethingsnetwork.org/ttn-eu/api/v2/down/acts083_test/mkr1300?key=ttn-account-v2.7Ph6lBffU7wI9cLY5ljIhIb_I7sqH5EVvo5zs9uVyA0',
type:'POST',
data:JSON.stringify({Makers:makers}),
contentType: "application/json; charset=utf-8",
dataType:"json",
success:function(response){
alert(response);
},
error:function() {
$('#error').text("There was an error while processing your request. Please try again");
}
});

답변 (0개)

커뮤니티

더 많은 답변 보기:  ThingSpeak 커뮤니티

카테고리

Help CenterFile Exchange에서 ThingSpeak에 대해 자세히 알아보기

태그

제품


릴리스

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by