We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Well, Im making progress. I finally got JSON into processing. Now I want to get it to update ever 4 seconds. In the console I can see the setInterval being called every 4 seconds so I know that bit of code seems to work, however it gives a Type Error saying pjs is undefined when I call the function from the SetInterval. It works fine when I call it from the onClick. Im struggling with javascript
<!DOCTYPE html> Print Text
<script src="processing.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script>
setInterval(getLastData,4000);
function getLastData(id)
{
var created_at;
var field1;
var field2;
var field3;
var field4;
var field5;
var field6;
var field7;
var field8;
var status;
var pjs = Processing.getInstanceById(id);
$.getJSON('https://api.thingspeak.com/channels/5384/feed/last.json?&status=true&callback=?', function(data) {
created_at = data.created_at;
field1 = data.field1;
field2 = data.field2;
field3 = data.field3;
field4 = data.field4;
field5 = data.field5;
field6 = data.field6;
field7 = data.field7;
field8 = data.field8;
status = data.status;
pjs.ParseData(created_at, field1, field2, field3, field4, field5, field6, field7, field8, status);
});
}
</script>
Answers
Have you taken a look @ my JS experiments in your other thread: :-t
http://forum.processing.org/two/discussion/3963/a-little-further-progress-but-now-getting-object-object