Im new to stack overflow so pls be patient with me.
JSON:
{"mcokzoo":{"id":48182210,"name":"mcokzoo","profileIconId":682,"summonerLevel":30,"revisionDate":1413774230000}}
Lets say I have the json above. I changed the data and removed stuff that didn't matter. I want the user to input their username into the search bar and then use that to find their id.
function getSummonerId(username)
{
url = summonerURL+"/by-name/" + username + key;
xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", url, false );
xmlHttp.send( null );
var jsonText = xmlHttp.responseText;
var summonerData = JSON.parse(jsonText);
//alert(jsonText)
return summonerData.(This is the part i have not clue)
}
Idk what to put in the above spot. I can't put the string name and I can seem to figure out how to put a variable name their correctly w/o hard coding. Any suggestions?
EDIT
I can't get it to work when i do window[variableName] also I read I wasn't suppose to use eval - also not working. Also I'm not using jquery which would also make the problem different