Learn all about the jQuery function deferred.promise().
deferred.promise() method allows an asynchronous function to prevent other code from interfering with the progress or status of its internal request. The Promise exposes only the Deferred methods needed to attach additional handlers or determine the state (
promise), but not ones that change the state (
target is provided,
deferred.promise() will attach the methods onto it and then return this object rather than create a new one. This can be useful to attach the Promise behavior to an object that already exists.
If you are creating a Deferred, keep a reference to the Deferred so that it can be resolved or rejected at some point. Return only the Promise object via
deferred.promise() so other code can register callbacks or inspect the current state.
For more information, see the documentation for Deferred object.