I have a very simple 2D array in a file called synergy_data.json:
[
['2014-08-19', 2956],
['2014-07-19', 2038],
['2014-06-19', 1285],
['2014-05-19', 1383],
['2014-04-19', 1256],
['2014-03-19', 822],
['2014-02-19', 644],
['2014-01-19', 504],
['2013-12-19', 438],
]
I'm trying to call up that data using ajax:
data=[]
$.ajax({
url: "/marquee/synergy_data.json",
async: false,
success: function(resultData) {
data = resultData;
}
});
console.log(data)
But the console only spits out "[]"
What am I doing wrong?
***Solution A big thanks to @Quentin for solving this for me. I had two fatal flaws with my JSON: 1) I used single quotes and 2) I had an extra comma. I'll be sure to use JSONLint to check my arrays in the future! (I also removed the "async:false" for good measure.)