I'm trying to get data from json(array of objects) file using $.getJSON but i found this error: "success" function can't be executed. But it is executing if json contents object What i'm doing wrong?
My code of JS and JSON below: JS:
$.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 2",
},
{
"user_name": "Name 2",
"user_company": "Company 2",
"message": "Message 2",
},
{
"user_name": "Name 3",
"user_company": "Company 3",
"message": "Message 3",
}
]