JSON Query in JS to define variable based on result | ThingSpeak API | Forum

Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
JSON Query in JS to define variable based on result
No permission to create posts
August 2, 2017
12:43 pm
Avatar
jteindl

Silver
Members
Forum Posts: 8
Member Since:
July 6, 2017
sp_UserOfflineSmall Offline

This is my code:

 

var bin1; 

function loadData() {

 

//

  $.getJSON('https://api.thingspeak.com/channels/276256/field/2/last.json?apikey=LP74006MCJC*****&callback=?', function(data) {

    bin1 = data.field2;

 

//

 

      if (bin1  > 40) {

bin1 = "True";

} else  {

bin1 = "False";

  }

});

 

I am trying to say, look at the result of Field2 using the Thingspeak API string, if the result is > 40 then define "bin1" as TRUE, else define as FALSE

 

What am I doing wrong....?

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online:
21 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 261

Vinod: 196

piajola: 85

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

Newest Members:

BarryMaync, ThomasRougs, DonaldGen, prince, JrGordon, Elamsweems

Administrators: Hans: 387, lee: 457