Work with legacy and simple sites using jQuery selectors, events, AJAX, effects, and plugins.
Lessons
Request JSON data and update the page after success or failure.
jQuery AJAX & JSON is easiest to learn by reading the example, changing it, and observing the result.
$('#loadLessons').on('click', function () {
$.getJSON('/api/lessons')
.done(function (lessons) {
$('#list').html(lessons.map(l => `<li>${l.title}</li>`).join(''));
})
.fail(function () {
$('#list').html('<li class="error">Could not load lessons</li>');
});
});Practice the jQuery AJAX & JSON example in a small scratch file, then explain what changed and why.