I have two functions both of which makes a jQuery call , the first one gets the champion ID and the second one gets the champion name using the ID, now I have 10 champion names to get so I'm using a for loop but it just won't work ...
This is my code :
function GetChampName(id) {
$.ajax({
url: 'https://global.api.pvp.net/api/lol/static-data/euw/v1.2/champion/' + id + '?api_key=f8453a98-ad2c-455e-b9df-f46c4f99d0ed',
datatype: 'json',
type: 'get',
success: function(json) {
sName = json.name;
}
});
return sName;
}
function summonerLookUp() {
var cn = [];
$.ajax({
url: 'https://euw.api.pvp.net/api/lol/euw/v1.3/game/by-summoner/46743451/recent?api_key=f8453a98-ad2c-455e-b9df-f46c4f99d0ed',
datatype: 'json',
type: 'get',
success: function(json) {
for (var i = 0; i <= json.games.length; i++) {
var id = json.games[i].championId;
$('#t1 tr:last').after('<tr> <td>' + json.games[i].gameId + '</td><td id="e">' + cn[i] + '</td><td>' + wl(json.games[i].stats.win) + '</td> </tr>');
}
}
});
}