title: Read data on your thing-speak channel using on/off button in jquery?
body: <p>I have the following code, it does the switch on and off. But I want now to be able read data on my <code>thingspeak</code> channel, when the value is 1 and value is 0 using the read channel url. I am struggling to this write, please help me and thanks.</p>
  
  <pre><code>&lt;div class = "wrapper" align = "center"&gt;
    &lt;div class="btn-group" id="toggle_event_editing"&gt;
    &lt;button type="button" class="btn btn-info locked_active"&gt;OFF&lt;/button&gt;
   &lt;button type="button" class="btn btn-default unlocked_inactive"&gt;ON&lt;/button&gt;
  &lt;/div&gt; 
  &lt;div class="alert alert-info" id="switch_status"&gt;Switched off.&lt;/div&gt;
   &lt;/div&gt;
  
    $('#toggle_event_editing button').click(function(){
      if($(this).hasClass('locked_active') || $(this).hasClass('unlocked_inactive')){
          /* code to do when unlocking */
          $('#switch_status').html('Switched on.');
  $.ajax({
      url:'https://api.thingspeak.com/update?api_key=DLQ0F7W5FGVO1I9Q&amp;field8=1',
      type:'GET',
      data:{
      format:'text'
        },
      success:function(response){
      alert(response);
        },
      error:function(){
      $('#error').text("There was an error while processing your request.Please try again");
      $('#singlebtn').append(data);
        }
  
        });
  
        }
  
      }else{
          /* code to do when locking */
          $('#switch_status').html('Switched off.');
  $.ajax({
      url:'https://api.thingspeak.com/update?api_key=DLQ0F7W5FGVO1I9Q&amp;field8=0',
      type:'GET',
      data:{
      format:'text'
        },
      success:function(response){
      alert(response);
        },
      error:function(){
      $('#error').text("There was an error while processing your request.Please try again");
      $('#singlebtn').append(data);
        }
  
        });
  
        }
      }
  
      /* reverse locking status */
      $('#toggle_event_editing button').eq(0).toggleClass('locked_inactive locked_active btn-default btn-info');
      $('#toggle_event_editing button').eq(1).toggleClass('unlocked_inactive unlocked_active btn-info btn-default');
  });
  </code></pre>