0

Possible Duplicate:
jQuery.ajax handling continue responses: “success:” vs “.done”?

Is there any benefit to using jquery's done method compared to the success callback ? As far as I can tell these would both execute similar (if not the same?)

Case 1 using $.get callback

$.get("....", function(data){
        console.log(data);
});

Case 2 using .done()

$.get("....").done(function(data){
     console.log(data);
});
Community
  • 1
  • 1
Matt
  • 1,265
  • 1
  • 16
  • 24

1 Answers1

2

You can attach any number of handler before or after it's processed and count on them all firing. You don't have to squeeze everything into a single function.

var request = $.get("....")
request.done(function(data) {
    console.log(data);
});
request.done(function(data) {
    // do something else
});
request.done(someOtherPredefinedFunction);

Besides, I believe the success handler is deprecated and scheduled for eventual removal.

Scott Sauyet
  • 49,207
  • 4
  • 49
  • 103