So I have a function in my code, that I'm calling using jQuery's getJSON. Here's the function:
public JsonResult GetItems()
{
var items = (from x in GetAllItems()
select new { x.ItemID, x.ItemType.Name, x.Description })
.ToList();
JsonResult result = Json(items, JsonRequestBehavior.AllowGet);
return Json(result, JsonRequestBehavior.AllowGet);
}
And this is where I'm calling it with jQuery:
$.getJSON('/MyController/GetItems/', function (data) {
// somehow iterate through items, displaying ItemID, Name, and Description
});
But I'm stuck here, I'm not sure what to do. I'd like to iterate through each item, and display the ItemID, Name, and Description in an alert box. But every example I've found just shows how iterate and display items that only have a key and a value, but my items have move than 2 properties to display.