I have some valid JSON as follows
[
{
"userFullName": "Tim, Bill",
"id": "LOt3",
"organisation": "FAP",
"loginSystem": "A",
"userId": 0
},
{
"userFullName": "Bruce, David",
"id": "LNA",
"organisation": "ES",
"loginSystem": "A",
"userId": 0
}
]
I am attempting to access the JSON elements in the success of an AJAX call as follows:
success: function (data) {
console.log('data ' + data);
$.each(data, function (key, value) {
console.log('id' + data[key].id);
$('#selectStaff').append('<option value="' + data[key].id + '">' + data[key].id + '</option>');
});
}
But data[key].id
is returning undefined
and if I just print out data[key]
, I get the individual characters of the array.
selectStaff
is the ID of a SELECT
.
What am I missing ?? Any help will be much appreciated.
Thanks