javascript - Undefined Returns on JSON Strings -


i wondering if able explain why of json returning undefined.. json question this

{"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 javascript i've got run through is:

note: in code provided /sumid 273746 , s 'oce' due riot api guidelines can't give direct link api had paste in above.

function statslookup(i,s) {

    $.ajax({      url: 'https://oce.api.pvp.net/api/lol/' + s + '/v2.5/league/by-summoner/' + + '/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!");         }     }); } 

everything continues return undefined, can't seem find issue @ hand :/

just make changes, code fine :

leaguename = json[sumid][0].name; leaguetier = json[sumid][0].tier; leaguediv  = json[sumid][0].entries[0].division; leagueloss = json[sumid][0].entries[0].losses; leaguewin  = json[sumid][0].entries[0].wins; 

this formatted json data :

{    "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             }          ]       }    ] } 

i hope help.


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -