The advantages of Promises and jQuery Deferred
The good point
The callback can be defined later on and fired even if the original promise already completed. When calling the promise.done(function(){}) it will fire even if the deferred is already completed - it will just execute right away.
The bad points
Performance.
Use it only when you have async behavior (which happens very often in Javascript). If your code is synchronous, do not use promises it is overkill.
Example of usage :
jQuery AJAX methods
var deferred = $.get('control/Get_SystemInfo.php', function(response)
{
});
(...)
deferred.done(function()
{
});
Recent Comments