Gcobani Mkontwana in MATLAB Answers
최근 활동: 2023년 9월 4일

Hi Team I am trying to read API key to my channel, using jquery to get JSON response to my channel. Here is my jquery logic, i am unable to get a response to my channel i have created and i want to read one field from my channel (field8) only. <script src="https://code.jquery.com/jquery-3.3.1.js"integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="crossorigin="anonymous"></script> <script type="text/javascript"> function loadData(){ var id; //get the data from thingspeak. $.getJSON('https://api.thingspeak.com/channels/899906/fields/8.json?api_key=F35GLOFJ8L99D0OM&results=2',function(data) { id = data.field8; if(id){ displayData(id); } }); } </script>
Gcobani Mkontwana in MATLAB Answers
최근 활동: 2021년 8월 19일

Hi Team I have this Ajax call request, it seem it does not working on my button to download date range, Strange part when i access this URL directly from the browser it can download this file format as CVS file on my local computer, Any idea as to why am i not able to get this write? Kindly please help, thanks. https://nl.mathworks.com/help/thingspeak/readdata.html $(document).ready(function() { $("#download").click(function() { $.ajax({ url:'https://www.thingspeak.com/channels/899906/feeds.csv?api_key=F**&results=3', type:'POST', dataType:'json', success:function(response){ window.location = response; } }); }); });
Gcobani Mkontwana in MATLAB Answers
최근 활동: 2019년 11월 26일

Hi Team Can any mate, help me i want to create a 1 button to toggle when it turn on and off. But it must be able to read an update field from my thingspeak channel. I have tried the followin <label for='opt2'></label> <input type='checkbox' name='opt2' id='opt2' value='1' class='toggleswitch' /> // on click button toggle. $(document).ready(function($) { $('.toggleswitch').toggleSwitch(); $("#opt2").trigger("click"); // turn it on if($(mainParent).find('input.toggleswitch').is(':checked')){ window.open('https://api.thingspeak.com/update?api_key=XXX&field8=1'); } }); g both HTML and Jquery no luck.
Gcobani Mkontwana in MATLAB Answers
최근 활동: 2019년 11월 10일

Hi Team I am using Jquery and communicate with my channel because i created a normal plugin for my UI. I want to find if there is a way in Jquery that you can download date range using datapicker, i am searching online nothing seem to appear similar to what i am aiming to achieve. Kindly please assist me thanks.
Gcobani Mkontwana in MATLAB Answers
최근 활동: 2019년 11월 7일

Hi Team I want to change the status of a message to be true, when the button is clicked 'on' and vice versa when is clicked off to be off. So far the functionality seem working not according to what i need it to be. e.g If my button is off, button continues to previous state as true(on). Off which i dont want that, want current state the button to be it remain and keep its value. Like if its on should be remain its value as on, same applies to off logic. I am struggling to get this work. I show you my code so far what i have done. <!---HTML code----> <body> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"><br/> <div class ="success"></div> <div class = "warning"></div> <div class="col-md-2 text-center"> <button id="singlebutton" name="singlebutton" class="btn btn-danger" onclick="BtnOff();">Off</button> <br> </div> <!------ ----> <br/> <div class = "col-md-2 text-center"> <button id = "singlebtn" name="singlebtn" class="btn btn-success" onclick = "BtnOn();">On</button> <br> </div> </body> </html> <!----Javascript code----> <script src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script> function BtnOff() { $.ajax({ url:'https://api.thingspeak.com/update?api_key=D****&field8=0', type:'GET', data:{ type:'text' }, success:function(response){ alert(response); $('div.warning').html('status changed to zero').delay(1000).fadeOut(); $('#singlebutton').append(data); } }); //setTimeout("Subscribe()", 100); } // second button to unsubscribe. function BtnOn() { $.ajax({ url:'https://api.thingspeak.com/update?api_key=*****&field8=1', type:'GET', data:{ type:'text' }, success:function(response){ alert(response); $('div.success').html('status changed to one').delay(1000).fadeOut(); $('#singlebtn').append(data); } }); //setTimeout("UnSubscribe()", 100); } </script>
Gcobani Mkontwana in MATLAB Answers
최근 활동: 2019년 11월 6일

Hi Team Is there any mate who can show me in Ajax, if there is better approach to read values in your ajax call request? That will read these values as they are passed on your parameter. What i want to achieve is similar to an example of light bulb, if the bulb is set true is on. If the bulb is set false is off. Now i want something similar to my below code logic for my current channel. Currently the buttons only accept these moment they are fired from the browser, i want a better approach and scale my application better. <div class="col-md-2 text-center"> <button id="singlebutton" name="singlebutton" class="btn btn-primary">Subscribe</button> <br> </div> <!------ ----> <br/> <div class = "col-md-2 text-center"> <button id = "singlebtn" name="singlebtn" class="btn btn-primary">Unsubscribe</button> <br> </div> <script src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script> $(document).ready(function(){ $.ajax({ url:'https://api.thingspeak.com/update?api_key=***&field8=0', type:'GET', data:{ format:'text' }, success:function(response){ alert(response); }, error:function() { $('#error').text("There was an error processing your request.Please try again"); $('#singlebutton').append(data); } }); // second button for unsubscribe. $(document).ready(function(){ $.ajax({ url:'https://api.thingspeak.com/update?api_key=***&field8=1', type:'GET', data:{ format:'text' }, success:function(response){ alert(response); }, error:function(){ $('#error').text("There was an error processing your request.Please try again"); $('#singlebtn').append(data); } }); }); }); </script>

ThingSpeak 정보

The community for students, researchers, and engineers looking to use MATLAB, Simulink, and ThingSpeak for Internet of Things applications. You can find the latest ThingSpeak news, tutorials to jump-start your next IoT project, and a forum to engage in a discussion on your latest cloud-based project. You can see answers to problems other users have solved and share how you solved a problem.