How do you have a link which text's changes based on JSON API's response?

How do you have a link which text's changes based on JSON API's response?
0.0 0

#1

On the TwitchTV JSON:
Html:
[left angle bracket]a href=“https://www.twitch.tv/freecodecamp” target= “_blank”>
[left angle bracket]h3 align=“center” id=“fccStatus”>

Javascript:
$.getJSON(url,function(data1){
if(data1.stream===null){
$("#fccStatus").html(“Free code camp is offline”);} else{
$("#fccStatus").html(“Free code camp is online”);}
});

I am trying to create text that say “Free code camp is on/offline”. I have tried moving the html and changing h3 to “span”.


#2

You can get code samples to appear properly by putting three backticks (key below the ESC) on the line before and three on the line after.

That being said, it should be pretty easy to change the text. With your HTML, I was able to do this:

var someBool = true;

setInterval( function() {
  if (someBool)
    $("#fccStatus").html("Free code camp is offline");
  else 
    $("#fccStatus").html("Free code camp is online");
  someBool=!someBool;
}, 1000);