Thingspeak talkback javascript

From emboxit
Revision as of 11:50, 1 April 2014 by NikoSysop (Talk)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Thingspeak-buttons-2.jpg

  • j.php

<javascript>

<!DOCTYPE HTML> <html> <head>

   <script type="text/javascript" src="http://code.jquery.com/jquery-1.11.0.min.js" ></script>
    
   <script type="text/javascript">    
       function btn_LED_ON() {
           $.ajax({
               url: "https://api.thingspeak.com/talkbacks/63/commands?key=29Z3EVEWFNBYC9NV&command_string=LED_ON&position=1",
               type: 'POST',
               success: function(data) {
               //called when successful
               console.log(data);
               //$('#results').append(data);
             }
           });
       }
       
       function btn_LED_OFF() {
           $.ajax({
               url: "https://api.thingspeak.com/talkbacks/63/commands?key=29Z3EVEWFNBYC9NV&command_string=LED_OFF&position=1",
               type: 'POST',
               success: function(data) {
               //called when successful
               console.log(data);
               //$('#results').append(data);
             }
           });
       }
       
       function btn_LED_BLINK() {
           $.ajax({
               url: "https://api.thingspeak.com/talkbacks/63/commands?key=29Z3EVEWFNBYC9NV&command_string=LED_BLINK&position=1",
               type: 'POST',
               success: function(data) {
               //called when successful
               console.log(data);
               //$('#results').append(data);
             }
           });
       }
       
       function btn_LED_BLINK_FAST() {
           $.ajax({
               url: "https://api.thingspeak.com/talkbacks/63/commands?key=29Z3EVEWFNBYC9NV&command_string=LED_BLINK_FAST&position=1",
               type: 'POST',
               success: function(data) {
               //called when successful
               console.log(data);
               //$('#results').append(data);
             }
           });
       }
       
   </script>

</head> <body>

Thingspeak API Buttons

</br>

<input id="LED_ON" width=200px type="button" value="ADD LED ON" onclick="btn_LED_ON();" />

<input id="LED_ON" width=200px type="button" value="ADD LED OFF" onclick="btn_LED_OFF();" />

<input id="LED_ON" width=200px type="button" value="ADD LED BLINK" onclick="btn_LED_BLINK();" />

<input id="LED_ON" width=200px type="button" value="ADD COMMAND LED_BLINK_FAST" onclick="btn_LED_BLINK_FAST();" />


<form action="https://www.thingspeak.com/channels/8053/feed.json?key=29Z3EVEWFNBYC9NV"> <input type="submit" value="JSON FEED"> </form> <form action="https://www.thingspeak.com/talkbacks/63/commands/133?key=29Z3EVEWFNBYC9NV"> <input type="submit" value="GET"> </form> <form action="https://www.thingspeak.com/talkbacks/63/commands/last?api_key=29Z3EVEWFNBYC9NV"> <input type="submit" value="LAST"> </form> <form action="https://www.thingspeak.com/talkbacks/63/commands?api_key=29Z3EVEWFNBYC9NV"> <input type="submit" value="LIST ALL"> </form> <form action="https://www.thingspeak.com/talkbacks/63/commands/execute?api_key=29Z3EVEWFNBYC9NV"> <input type="submit" value="EXECUTE"> </form>

</body> </html>

</javascript>