Hit a Wall on Twitchtv API

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!

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:

1 Like

Exactly what I needed, thank you!

1 Like

I found …ajaxStop() to be very helpful