Time remaining:
Hide/Show Text/Image w/ Javascript/HTML

Programming
Tutor: None Selected Time limit: 0 Hours

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.
http://api.justin.tv/api/stream/list...annel=defatank
If the channel is live, it will display something like:

Code:

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

Code:

[]
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.

Nov 30th, -0001
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
          $('#result').html(data);});
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.

<script>

$(function() {

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

//data is the thing you get..

if(data == "[]"){

//do sth.

}else{

//do sth.
}
});

</script>

Jun 11th, 2013

Studypool's Notebank makes it easy to buy and sell old notes, study guides, reviews, etc.
Click to visit
The Notebank
...
Nov 30th, -0001
...
Nov 30th, -0001
May 29th, 2017
check_circle
Mark as Final Answer
check_circle
Unmark as Final Answer
check_circle
Final Answer

Secure Information

Content will be erased after question is completed.

check_circle
Final Answer