I have an MVC5 project that uses this jQuery AJAX call
$.ajax({
url: "/ClientDetails2/" + document.getElementById('clientid').value,
type: "GET",
dataType: "json"
})
.done(function (json) {
$('#FirstName').text(json['Client'].FirstName);
$.each(json['Cases'], <-----
function(value) { <-----
console.log(value); <-----
}); <-----
});
to return this JSON:
{
Client: {
Id: 1,
LastName: "Clark",
FirstName: "Keith",
PrimaryPhone: "(555) 555-1212",
Email: "[email protected]"
},
Cases: [
"Case1",
"Case2",
"Case3"
]
}
The $('#FirstName').text(json['Client'].FirstName); works fine and updates the DOM correctly.
Where I am getting hung up is in iterating thru Cases.
What am I missing here?
Thanks, Keith Clark
.eachoption as I will never know how many items are in that array