I'm sure this is a simple one, and I'm close, but can't get exactly what I want.
The end result I need to create (in HTML) is like this:
<li id="EventList">
<ul class="calendar-menu">
<li>
<time class="anthracite"><b>24</b> Feb</time>
<small class="green">10:30</small>
Event's description
</li>
<br />
<li>
<time class="anthracite"><b>24</b> Feb</time>
<small class="green">10:30</small>
Event's description
</li>
<br />
<li>
<time class="anthracite"><b>24</b> Feb</time>
<small class="green">10:30</small>
Event's description
</li>
</ul>
I need to fill in the date, time and description elements dynamically, based on data that I get from an ajax call to the database.
Here's what I have been trying to get to create the HTML list. Eventually the data will come from
function GetList() {
$.ajax({
async: false,
type: "POST",
contentType: "application/json; charset=utf-8",
url: "ExampleList.aspx/GetList",
dataType: "json",
success: function (data, textStatus) {
if (textStatus == "success") {
var datos = jQuery.parseJSON(data.d);
$("#EventList").html('');
var list = '<ul>'
$.each(datos, function (i, v) {
Something in here to populate the <li> tags?
});
list += '</ul>'
$("#EventList").append(list);
}
},
error: function (request, status, error) {
alert(jQuery.parseJSON(request.responseText).Message);
}
});
}
Is anyone able to point me in the right direction with some example code?
datosobject but basically you can create some HTML string by joining bits of hard-coded HTML strings to your object's properties. e.g.list += <li><time class="anthracite"><b>' + v.whateverYourHoursFieldIsCalled + '</b>'...etcappend(thing)in a$, i.e.$("#EventList").append($(list));<br />tags between your list items in invalid HTML.