Can anyone shed some light on why all my JSON data is showing up as Undefined? Here is the JSON snippet in question:
{"273746":[{"name":"Darius's Wizards","tier":"GOLD","queue":"RANKED_SOLO_5x5","entries":[{"playerOrTeamId":"273746","playerOrTeamName":"Magnanimous","division":"V","leaguePoints":0,"wins":19,"losses":15,"isHotStreak":false,"isVeteran":false,"isFreshBlood":false,"isInactive":false}]}]}
And here is the JavaScript code I'm using to process this data:
Note: In the code snippet, i /sumID is 273746 and s is 'oce' in adherence to Riot API guidelines.
function statsLookUp(i,s) {
$.ajax({
url: 'https://oce.api.pvp.net/api/lol/' + s + '/v2.5/league/by-summoner/' + i + '/entry?api_key=',
type: 'GET',
dataType: 'json',
data: {
},
success: function (json) {
//all json goes here
var sumID = i;
leagueName = json[sumID].name;
leagueTier = json[sumID].tier;
leagueDiv = json[sumID].entries.division;
leagueLoss = json[sumID].entries.losses;
leagueWin = json[sumID].entries.wins;
document.getElementById("sLeague").innerHTML = leagueName;
document.getElementById("sTier").innerHTML = leagueTier;
document.getElementById("sDivision").innerHTML = leagueDiv;
document.getElementById("sWins").innerHTML = leagueWin;
document.getElementById("sLosses").innerHTML = leagueLoss;
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert("error getting Summoner data!");
}
});
}
Despite my efforts, everything keeps showing up as undefined. Can't seem to pinpoint the issue at hand :/