I'm very new to using JSON with AJAX so I'm not sure what I'm doing wrong. I've looked up various examples, but can't seem to pull the JSON data correctly. I believe it's how my JSON file is set up. I've tried with other examples and got it to work, but the way mine is written is different. Can anyone help me? I need to be able to output the data from the JSON object.
My JSON looks like this:
[
{
"ID": 512,
"FirstName":"John",
"LastName":"Smith",
"Age":26,
"Email":"johnsmith@gmail.com",
"Phone1":"555-555-5555",
},
{
"ID": 513,
"FirstName":"Jane",
"LastName":"Smith",
"Age":24,
"Email":"janesmith@gmail.com",
"Phone1":"555-555-5555",
},
]
My script is below:
$.getJSON("test.json", function (data) {
$.each(data, function (index, value) {
var items = [];
$("div").append(items);
});
});
I'm not sure how get the values inside the JSON object for my variable of items. Any help would be greatly appreciated!