JQuery deferred.notifyWith() method Last Updated : 24 Jul, 2024 Comments Improve Suggest changes Like Article Like Report This deferred.notifyWith() method in JQuery is used to call the progressCallbacks on a Deferred object along with the provided context and args. Syntax: deferred.notifyWith(context[, args])Parameters: context: This parameter is the context passed to the progressCallbacks as the 'this' object. args: This parameter is an optional array of arguments which are passed to the progressCallbacks. Return Value: This method returns the deferred object. There are two examples discussed below: Example 1: In this example, We notify the Deferred object with two arguments and process any progressCallbacks before rejecting it. html <!DOCTYPE HTML> <html> <head> <title> jQuery | deferred.notifyWith() method </title> <script src="https://code.jquery.com/jquery-3.5.0.js"></script> </head> <body style="text-align:center;"> <h1 style="color:green;"> GeeksForGeeks </h1> <p id="GFG_UP"></p> <button onclick="Geeks();"> Click Here </button> <p id="GFG_DOWN"></p> <script> var el_up = document.getElementById("GFG_UP"); el_up.innerHTML = "JQuery | deferred.notifyWith() method"; function Func(val, div) { $(div).append('From function "Func": ' + val); } function Geeks() { var def = $.Deferred(); def.progress(Func); def.notifyWith( this, ['notifyWith() is called with arguments. <br />', '#GFG_DOWN']); } </script> </body> </html> Output: Example 2: In this example, We notify the Deferred object with only one arguments and process any progressCallbacks before resolving it. html <!DOCTYPE HTML> <html> <head> <title> jQuery | deferred.notifyWith() method </title> <script src="https://code.jquery.com/jquery-3.5.0.js"> </script> </head> <body style="text-align:center;"> <h1 style="color:green;"> GeeksForGeeks </h1> <p id="GFG_UP"></p> <button onclick="Geeks();"> click here </button> <p id="GFG_DOWN"></p> <script> var el_up = document.getElementById("GFG_UP"); el_up.innerHTML = "jQuery | deferred.notifyWith() method"; function Func(val, div) { $(div).append('From function "Func": ' + val); } function Geeks() { var def = $.Deferred(); def.done(Func); def.progress(Func); def.notifyWith(this, ['#GFG_DOWN']); def.resolve('Deferred is resolved.<br />', '#GFG_DOWN') } </script> </body> </html> Output: Comment More infoAdvertise with us Next Article JQuery deferred.notifyWith() method P PranchalKatiyar Follow Improve Article Tags : JavaScript Web Technologies JQuery jQuery-Methods Similar Reads JQuery deferred.notify() method This deferred.notify() method in JQuery is used to call the progressCallbacks on a Deferred object with the given parameters. Syntax: deferred.notify(params)Parameters: params: This is optional parameters which are passed to the progressCallbacks. Return Value: This method method returns the deferre 2 min read jQuery deferred.rejectWith() Method This deferred.rejectWith() method in jQuery is used to reject a Deferred object and call the failCallbacks along with the given context and arguments. Syntax: deferred.rejectWith(context[, args])Parameters: context: This parameter is the context passed to the failCallbacks as the 'this' object. args 2 min read jQuery deferred.resolveWith() Method This deferred.resolveWith() method in jQuery is used to resolve a Deferred object and call the doneCallbacks along with the given context and arguments. Syntaxdeferred.resolveWith(context[, args])Parameterscontext: The context passed to the doneCallbacks as the 'this' object. args: It is an optional 2 min read JQuery deferred.then() method This deferred.then() method in JQuery is used to add handlers which are to be called when the Deferred object is resolved, rejected, or in progress. Syntax: deferred.then(doneCallbacks[, failCallbacks][, progressCallbacks])Parameters: doneCallbacks: This is a function, or an array of functions, whic 3 min read JQuery deferred.state() method This deferred.state() method in JQuery is used to determine the current state of a Deferred object. Syntax: deferred.state()Return Value: This method returns the state of deferred object. There are two examples discussed below: Example: In this example, the state of deferred object 'def' is pending. 2 min read Like