2018-04-11 06:42:43 +08:00
|
|
|
$(document).ready(function () {
|
2018-04-19 04:35:05 +08:00
|
|
|
// Send an AJAX request
|
|
|
|
$.getJSON(apiUrl)
|
|
|
|
.done(function (data) {
|
|
|
|
// On success, 'data' contains a list of todos.
|
2018-04-11 06:42:43 +08:00
|
|
|
$.each(data, function (key, item) {
|
2018-04-19 04:35:05 +08:00
|
|
|
// Add a list item for the todo.
|
|
|
|
$('<li>', { text: formatItem(item) }).appendTo($('#todos'));
|
2018-04-11 06:42:43 +08:00
|
|
|
});
|
2018-04-19 04:35:05 +08:00
|
|
|
});
|
|
|
|
});
|