I have the following C# class:
public class JsonBackup
{
public int Added { set; get; }
public int DEVCount { set; get; }
public int DS1Count { set; get; }
public IList<ViewEvent> Events { get; set; }
}
and this is used to return a Json string like this:
return Json(new JsonBackup
{
Added = added,
DEVCount = devCount,
DS1Count = ds1Count,
Events = t.Events
});
I have the following javascript call:
$.ajax({
url: $(this).attr('data-href'),
dataType: 'json',
type: 'POST'
})
.done(function (data) {
backupDone(data, ajaxElapsed);
})
I know that I can get the data.Added etc properties but how can I get the Event information that’s
part of the Events list?
Here’s an example of the C# class that has the event data:
public class ViewEvent {
public long Elapsed { get; private set; }
public ET EventType { get; private set; }
public string Description { get; private set; }
public string Message { get; private set; }
public int Quantity { get; private set; }
}
What I really need is some JQuery or javascript way to get the following information out of what is returned from the Ajax call and add it to the ul element with the id=”stats”
<li>@viewEvent.Description : @viewEvent.Elapsed ms</li>
The code you need in your done function would look something like this: