I am having some issues with synchronous calls, and can't seem to understand exactly what's going wrong.
When debugging the code, it fills up the songTracks array perfectly, just until the return statement, where it is empty again.
Code sample:
function getAllSongIds(lijstId){
var songTracks = [];
$.ajax({
url: "http://somehost.com/lists/"+lijstId+"/editions/",
dataType: "jsonp",
async: false,
success: function(json){
for (i in json.editions) {
$.ajax({
url:"http://somehost.com/lists/"+lijstId+"/editions/"+json.editions[i].id,
dataType:"jsonp",
async: false,
success: function(json2){
for(j in json2.tracks){
if(songTracks.indexOf(json2.tracks[j].id) === -1){
songTracks.push(json2.tracks[j].id);
}
}
}
})
};
}
});
alert(songTracks);
return songTracks;
};