Work with legacy and simple sites using jQuery selectors, events, AJAX, effects, and plugins.
Lessons
Configure full requests with method, data, and callbacks.
The $.ajax() Method is easiest to learn by reading the example, changing it, and observing the result.
$.ajax({
url: '/api/lessons',
method: 'POST',
contentType: 'application/json',
data: JSON.stringify({ title: 'AJAX lesson' })
})
.done(function (response) {
$('#output').text('Saved: ' + response.id);
})
.fail(function (xhr) {
$('#output').text('Error: ' + xhr.status);
})
.always(function () {
$('#spinner').hide();
});Practice the The $.ajax() Method example in a small scratch file, then explain what changed and why.