I am wondering about some redundant functionality in jQuery and hope someone could shed some light into it.
jQuery.getJSON()
takes as third argument a callback function for the successful completion of the request, but at the same time getJSON()
also returns a jqXHR
object which also comes with three callback functions (always()
, done()
and fail()
).
Now my question is whether there is any semantical difference between passing the desired function as third parameter or as argument to done()
(also in terms of best practices), respectively if there are any advantages or disadvantages in using either. As for the latter, the only disadvantage I could imagine (even though rather unlikely as scenario) is a timing issue in case the request is processed faster than the done()
call can bind the passed function.