Okay, I think I may be retarded, but I can't figure this out for some reason.
I have this code.
var x = [];
$.getJSON('data.json', function(data) {
$.each(data, function(key, val) {
x.push(val);
});
});
console.log(x);
It prints this to console.
I cannot for the life of me figure out how to access x or y. Can someone explain to me how this works?
json:
[
{
"x": 121.87375,
"y": 483.7810417
},
{
"x": 116.831875,
"y": 471.9985417
},
{
"x": 111.694375,
"y": 460.0341667
}
]
I just want to be able to do a for loop and update x and y to the next index every second.