Hit a Wall on Twitchtv API

Hit a Wall on Twitchtv API
0.0 0

#1

Well, I was cruising through most of the projects so far but this Twitchtv one has me stumped. I just have no idea why it is not putting the twitch api responses into my project. I originally had it working a bit better using a whole bunch of nested callbacks but it seemed like spaghetti code and was having strange bugs like looping through the last channel in my array repeatedly.

I broke everything up and now I basically have a for loop that makes two requests, followed by an if/else that appends the html and data for a stream that is offline or online. However nothing is loading in, and I think it has something to do with the asynchronous way that requests are made, but I don’t fully understand. Any help is appreciated, thanks!


#2

The for loop finishes before the $.getJSON goes. Asynchronous requests do not work in loops, nor do they work well one right after another.

This will help:
http://thenetninja.co.uk/courses/asynchronous-javascript-tutorial


#3

Exactly what I needed, thank you!


#4

I found …ajaxStop() to be very helpful