0

I've been reading for hours on this json stuff and the justin.tv API documenation but still unable to get the number of viewers currently viewing my stream.

Here's a json script I tried, nothing happens.

    var url = "http://api.justin.tv/api/stream/list.json";

    $.ajax({
       url: url,
       dataType: 'jsonp',
       data: { channel: "dreamvoid"},
       success: function(data) { $('#result').text(JSON.stringify(data.stream_count)); },
       jsonp: 'jsonp'
    });
Petter Thowsen
  • 1,697
  • 1
  • 19
  • 24

1 Answers1

0

Your request is returning JSON, not JSONP. Please refer to the justin.tv api documentation to get it to return proper JSONP. If you cannot get it to return JSONP, you will need to either use YQL or implement a server-side proxy to make the request for you.

Also, JSON.stringify(data.stream_count) should be data.stream_count.

Kevin B
  • 94,570
  • 16
  • 163
  • 180