Time remaining:

Hide/Show Text/Image w/ Javascript/HTML

account_circle Unassigned
schedule 0 Hours
account_balance_wallet $5

I don't know if this can be done. I imagine it's pretty simple. I just don't know enough about Javascript to build it correctly.

I have an Enjin.com site. They allow me to use HTML modules with Javascript enabled. What I am trying to do is display whether a Twitch.tv streamer is broadcasting(Live) or not. Twitch has APIs you can use to check.
If the channel is live, it will display something like:


[{"broadcast_part": 1, "featured": false, "channel_subscription": false,...etc.
If they are not live it will simply display


Javascript needs to check that API URL, determine whether the content is > or = "[]", then display or hide some text or image based on that. How can I do this?

Thank you for your help.

Mar 20th, 2018
Ok, you can't really determine they are live or not by testing out the code. Why not just use the same API to test it's > or = []? You've been using this to determine it's [] or [codes] anyway.
Jun 10th, 2013

No I haven't done anything. That is only an API link provided by Twitch. I have no code myself. This is what I am asking help for.

Jun 11th, 2013

OK this is tricky. Because of security reason, Jquery does not allow you to load data from other website directly. So you will need to use PHP to do sth. like this first:

$.post("/sites/scripts/my_script.php",{"post_parameter":"post_value"},function(data){// put the result into a div
However, you can try this if you are not familiar with PHP/python.

Download this first: http://james.padolsey.com/javascript/cross-domain-requests-with-jquery/

Include it in your project.


$(function() {

$.get('ajax/test.html', function(data) {

//data is the thing you get..

if(data == "[]"){

//do sth.


//do sth.


Jun 11th, 2013

Did you know? You can earn $20 for every friend you invite to Studypool!
Click here to
Refer a Friend
Mar 20th, 2018
Mar 20th, 2018
Mar 21st, 2018
Mark as Final Answer
Unmark as Final Answer
Final Answer

Secure Information

Content will be erased after question is completed.

Final Answer