I think the second success callback in this example simply illustrates that using this syntax, you can have multiple handlers for the success
, error
and complete
events. In the standard jQuery .ajax()
method, you can only assign one handler for each of these events. I can't come up with an example that would require several handlers, but it looks a bit clearer and looks more like the standard jQuery idiom for using
$.get('my_url.php') .success(handlerOne) .success(handlerTwo);
instead
$.get('my_url.php', function(data, textStatus, jqXHR) { handlerOne(data, textStatus, jqXHR); handlerTwo(data, textStatus, jqXHR); });
In your case, it might be easier and cleaner to just convert your $.get()
statements to $.ajax()
. The syntax of $.ajax()
is probably better known to most jQuery programmers, and since you donβt need the special functions (multiple handlers, assigning a handler after a request) available in another syntax, there is no reason not to just use $.ajax()
$.ajax({ url: url, success: function(data) {
source share