1

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

orwinmc
  • 168
  • 1
  • 13
  • Is there a form you are using? The fields would have ids/names. – Code Whisperer Oct 20 '14 at 19:53
  • The json is erroneous... Give the correct JSON and also what is "jetstream" here? is this what you want to search..?? – void Oct 20 '14 at 19:55
  • the "jetstream" is the username that i have collected from the field – orwinmc Oct 20 '14 at 19:59
  • I also haven't done the form yet 'Code Whisperer' I just thought once I got this working it would be as simple as adding text field and button to submit data – orwinmc Oct 20 '14 at 20:00

0 Answers0