So I have a jQuery .getJson which is as so:
var tournamentdata = [];
$.getJSON( "http://tourn.dev/data/tournaments", function( data ) {
$.each(data, function(i) {
var tempdata = [];
$.each(this, function(k, v) {
tempdata.push(v);
});
tournamentdata.push(tempdata);
});
});
console.log(tournamentdata);
The JSON request returns:
[
{
"id":1,
"name":"one",
"max_users":100,
"registered_users":0,
"prize_pool":1000,
"entry_fee":10,
"published":0,
"registration_open_date":"0000-00-00 00:00:00",
"registration_close_date":"0000-00-00 00:00:00"
,"start_date":"0000-00-00 00:00:00",
"created_at":"2015-04-28 20:35:23",
"updated_at":"2015-04-28 20:35:23"
},
{
"id":2,
"name":"Two",
"max_users":1000,
"registered_users":0,
"prize_pool":10000,
"entry_fee":100,"published":0,
"registration_open_date":"0000-00-00 00:00:00",
"registration_close_date":"0000-00-00 00:00:00",
"start_date":"0000-00-00 00:00:00",
"created_at":"2015-04-28 20:37:16",
"updated_at":"2015-04-28 20:37:16"
}
]
Now, when I check my console log in firefox the tournamentdata is an array of two arrays 'Array [ Array[12], Array[12] ]'.
However, when I try access the multi-array through something like:
alert(tournamentdata[0][0]);
it returns undefined.