I'm encountering an issue while attempting to retrieve data from a json file (an array of objects) using $.getJSON. The problem is that the "success" function isn't being executed, despite it working when the json contains only one object. What could I be doing incorrectly?
Here's my JavaScript and JSON code snippets:
$.getJSON('test2.json', function(data){
console.log('getJSON callback works');
$.each(data, function(idx, obj){
$.each(obj, function(key, value){
console.log(key + ": " + value);
});
});
});
JSON:
[
{
"user_name": "Name 1",
"user_company": "Company 1",
"message": "Message 1"
},
{
"user_name": "Name 2",
"user_company": "Company 2",
"message": "Message 2"
},
{
"user_name": "Name 3",
"user_company": "Company 3",
"message": "Message 3"
}
]