It looks like my for loop is looping the last object parsed into all fields.
http://codepen.io/anon/pen/EKxNaN
This is the actual code I am using, I built something kind of similar for codepen since I cannot request JSON from the actual source on codepen.
var championMasteryPHP = "https://api.myjson.com/bins/xked";
$.getJSON(championMasteryPHP, function (json) {
for (var i = 0; i < json.length; i++) {
var champID = json[i].championId;
var champLevel = json[i].championLevel;
var pointstonextlevel = json[i].championPointsUntilNextLevel;
var championInfo = "http://example.com/champInfo.php?champid=" + champID;
$.getJSON(championInfo, function (json2) {
var champName = json2.name;
var champTitle = json2.title;
$('#champ').append("<li>ID: " + champID + " | Name: " + champName + " | Level: " + champLevel + " | Points to Next Level: " + pointstonextlevel + "</li>");
});
};
});
Long story short, what I am trying to achieve would look like this.
But for some reason, this is what I get instead.
The right names, but the other variables are the very last variable in the listing.
Is there a better way to do this? Am I doing something terribly wrong?
Thanks.