June 2013
Beginner
444 pages
9h 45m
English
Introducing any kind of network interaction into an application brings along some degree of uncertainty. The user's connection could drop in the middle of an operation or a temporary server issue could interrupt communications. Because of these reliability concerns, we should always plan for the worst case and prepare for error scenarios.
The $.ajax() function can take a callback function named error to be called in these situations. In this callback, we should provide some kind of feedback to the user indicating that an error has occurred:
$(document).ready(function() {
var $ajaxForm = $('#ajax-form'),
$response = $('#response'),
noresults = 'There were no search results.',
failed = 'Sorry, but the request could not ' +