Send asynchronous browser requests with fetch, XMLHttpRequest, JSON, errors, and progressive UI.
Lessons
Use $.ajax, $.get, and $.post in legacy projects.
AJAX with jQuery is easiest to learn by reading the example, changing it, and observing the result.
// Legacy jQuery AJAX
$.ajax({
url: '/api/lessons',
method: 'GET',
dataType: 'json'
})
.done(function (lessons) {
$('#list').html(lessons.map(l => `<li>${l.title}</li>`).join(''));
})
.fail(function (xhr) {
console.error('Error', xhr.status);
});Practice the AJAX with jQuery example in a small scratch file, then explain what changed and why.