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

Avatar

Please consider registering
Guest

Search

— Forum Scope —






— Match —





— Forum Options —





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

Register Lost password?
sp_Feed sp_TopicIcon
JSON Query in JS to define variable based on result
Avatar
jteindl

Silver
Forum Posts: 8
sp_UserOfflineSmall Offline
1
August 2, 2017 - 12:43 pm
sp_Permalink sp_Print

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: jacktheripper125
20 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 252

Vinod: 164

cstapels: 96

piajola: 75

vespapierre: 63

Adarsh_Murthy: 59

Newest Members:

Nsneilotof

angieus2

goldiepw11

BinanceoSt

gnarender123@gmail.com

edenderest

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

 

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Administrators: Hans, lee