What is the difference between return defand refunddef.promise()
def
def.promise()
var def = $.Deferred(); // some code to set def return def; // or return def.promise();
A deferred may be allowed or rejected by its caller. A promise to be made to any number of consumers, and each will observe the resolution independently.
This concept does not allow consumers to change the state of Deffered, and this is a cool feature.
http://blog.mediumequalsmessage.com/promise-deferred-objects-in-javascript-pt1-theory-and-semantics