Skip to main content

.success() and .error() still supported in jQuery 1.9.1

By Sam Deering

JavaScript

Share:

Free JavaScript Book!

Write powerful, clean and maintainable JavaScript.

RRP $11.95

Just a quick note that you can still use .success() and .error() in jQuery 1.9.1 and it won’t break your code. I do however highly recommend using the new promise interface with callback methods .done() and .fail() – See AJAX before jQuery 1.8 and After on code differences.

They have backwards compatiability in jQuery 1.9.1. Let’s look at the source pay attention to the alias lines.

//https://code.jquery.com/jquery-latest.js (v1.9.1)

// Attach deferreds (line 7835-7838)
deferred.promise( jqXHR ).complete = completeDeferred.add;
jqXHR.success = jqXHR.done;
jqXHR.error = jqXHR.fail;

//...

// Install callbacks on deferreds  (line 7951-7954)
for ( i in { success: 1, error: 1, complete: 1 } ) {
  jqXHR[ i ]( s[ i ] );
}

//...

// Success/Error (line 8072-8077)
if ( isSuccess ) {
  deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
} else {
  deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
}

Sam Deering has 15+ years of programming and website development experience. He was a website consultant at Console, ABC News, Flight Centre, Sapient Nitro, and the QLD Government and runs a tech blog with over 1 million views per month. Currently, Sam is the Founder of Crypto News, Australia.

New books out now!

Get practical advice to start your career in programming!


Master complex transitions, transformations and animations in CSS!