I have this array:
0: {links: www.example.com, coordinates: 8.99, 5.00}
1: {links: www.exampleB.com, coordinates: 5.99, 2.00}
And on ajax success I need to push each single value to an array, I tried:
success: function(data) {
coords = [];
for (var i = 0; i < data.length; i++) {
coords.push(data.coordinates[i]);
};
...
But I get:
Uncaught TypeError: Cannot read property '0' of undefined
On this line:
coords.push(data.coordinates[i]);
I have this array:What exactly are you logging there?datais an array so you need to index into it to get at one set of coordinates:data[i].coordinates[j]