If you connect the function directly to the call, the difference in use is small. The difference arises when you want to have a callback function somewhere else.
Sending a callback function to a method:
function callForMe(callback) {
$.ajax({
url: '...',
success: callback
});
}
callForMe(function(data){
});
Return the promise of the method, waiting for a response later:
function callFormMe() {
return $.ajax({
url: '...'
});
}
var promise = callForMe();
promise.done(function(data){
});
Guffa source
share