Changing image based on whether a channel is live or not

I am trying to create a simple json call coupled with an if function to display whether a channel is live or not. I am not a very good developer, but I am trying to make it work for one stream for one site. If someone could point out where my error is, that would be much appreciated. Thank you!


<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script>
	$.getjson('https://api.twitch.tv/kraken/streams/LegacyObserver', function(channel) {

		if (channel["stream"] == "null") { 
		document.write("<img src='/grafx/offline.jpg'>");

		} else {
		document.write("<img src='/grafx/online.jpg'>");
		}
	        });
</script>
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="https://cdn.rawgit.com/Fugiman/Twitch-Channel-Status/1d74252edf89110507cbf3088f9c3eaa38fac9d3/twitch-channel-status.min.js"></script>
<img data-twitch-channel="legacyobserver" data-online-image="/grafx/online.jpg" data-offline-image="/grafx/offline.jpg">
4 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.