0

I have a little problem. I want ot get information for current user from json url, but my Username is in variable. When I try to get and show information for current user name by ($('#result').append(data.users.Username);) nothing happans. But if you do $('#result').append(data.users.Admin); everything is work. My question is how to get infromation for current user when username is in variable? I will be very thankful if someone help. Thanks.

$('#start').on('click', function() {
    var Username = $('#Username').val();
    $.ajax({
        url: 'jsonurl,
        dataType: 'json',
    })
    .done(function(data) {
        $('#result').html('');
        $('#result').append(data.users.Username);
    });
    return false;
});
Oleksandr T.
  • 76,493
  • 17
  • 173
  • 144
diank
  • 628
  • 2
  • 11
  • 19

1 Answers1

1

You can use bracket notation [], like so

data.users[Username]
Oleksandr T.
  • 76,493
  • 17
  • 173
  • 144