F
F
foxayb2019-09-30 21:43:39
JavaScript
foxayb, 2019-09-30 21:43:39

How to get data from multidimensional array?

For example, here is an array: https://pastebin.com/aN6NNWj1

How to get and output: steamid

$.getJSON('http://whateverorigin.org/get?url=' + 
    encodeURIComponent('http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=1CD46A47F34C832CAC9A45FB0759CFF5C2C&steamids=7656119793360435530') + '&callback=?',
    function (data) {
        console.log("> ", data);
        for (var i in data.response.players) {
         alert(data.response.players[i].steamid);
        };
        		  
//$('.itd .sp').text(data.contents.Response.Players[0].steamid);
//If the expected response is text/plain
//$('.itd .sp').html('<img id="thePoster" src=' + 'http://cdn.akamai.steamstatic.com/' + data.response.avatarfull + ' />');
        //If the expected response is JSON
        //var response = $.parseJSON(data.contents);
});

Writes an error Cannot read property 'players' of undefined

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question