I first get a JSON playlist of videos. I then get JSON information on each video id that was provided in the playlist. From each video information JSON I want to list the video's thumbnail url in the "#container" div.
My issue is that the order of thumbnails changes every time I hit the "Get JSON data" button. I looked in the console and the individual video JSON is always queried in the same order, it's just that when I post information from that JSON it's not in order.
What gives?
$(document).ready(function(){
$("button").click(function(){
//$('p').remove();
$.getJSON("https://api.dailymotion.com/playlist/xy4h8/videos",function(result){
$.each(result.list, function (index, value) {
// console.log(value.id);
$.getJSON("https://api.dailymotion.com/video/"+value.id+"?fields=id,title,thumbnail_medium_url",function(resulted){
$("#container").append(resulted.thumbnail_medium_url + "<br />"); // THIS IS THE BIT ALWAYS OUT OF ORDER
}); // use id of each object in list to get next json
}); // for each of the list object within the playlist result obj
}); // get playlist json
}); // button click
});
Thanks for any help.