O'Reilly logo

jQuery and JavaScript Phrasebook by Brad Dayley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Handling jQuery AJAX Responses

$.get("getUser.php?first=Brad&last=Dayley", null, function (data, status, xObj){   alert("Request Succeeded"); }), "json").fail(function(data, status, xObj){   alert("Request Failed"); }).always(function(data, status, xObj){   alert("Request Finished"); });

In addition to specifying the success option, the wrapper methods also allow you to attach additional handlers using the following methods:

Image .done(data, textStatus, jqXHR)—Called when a successful response is received from the server.

.fail(data, textStatus, jqXHR)—Called when a failure response is received from the server or ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required