Sorry for basic question, but this doesn't seem like properly formed JSON to me. I am reading this structure in from a file that returns this:
states([{"code":"AL","name":"Alabama"},{"code":"AK","name":"Alaska"},{"code":"AZ","name":"Arizona"}])
When I did a JSON Lint on this, it fails - but its what I have to work with, as this is a file on a server separate from mine.
I expected it to be var stores = [{stuff}], I have yet to see the JSON saved like above, but again - I'm noob
I'm using Angular to read this in, so here's what I have in my code:
var directory = this;
directory.states = [];
$http.get('http://somesite.com/js/states.json').success(function(data){
directory.states = data;
});
Here is the file I am having problems with: http://massachusettswebdesigns.com/states.json
If I treat the states in the file as a variable, I get an undefined error:
var state = data.states;
Its not really a function either.
Any Ideas? I guess I could treat the whole thing as a string and split off the states( part, but I am thinking that there is an easier solution that I am just missing.