// Assign handlers immediately after making the request,// and remember the jqxhr object for this requestvar jqxhr = $.getJSON( "example.json",function() {console.log( "success" );}).done(function() { console.log( "second success" ); }).fail(function() { console.log( "error" ); }).always(function() { console.log( "complete" ); });// perform other work here ...// Set another completion function for the request abovejqxhr.complete(function() { console.log( "second complete" ); });jqXHR.success()jqXHR.error()jqXHR.complete()jqXHR.done()jqXHR.fail()jqXHR.always()Deprecation Notice
The,andcallback methods introduced in jQuery 1.5 aredeprecated as of jQuery 1.8. To prepare your code for their eventual removal,use,andinstead.