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.
<!DOCTYPE HTML> <html> <head> <title> JQuery | deferred.notifyWith() method </title> <script src= </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.
<!DOCTYPE HTML> <html> <head> <title> JQuery | deferred.notifyWith() method </title> </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:

Recommended Posts:
- jQuery | jQuery.fx.interval Property with example
- jQuery | jQuery.fx.off Property
- jQuery | jQuery.support Property
- jQuery | jquery Property
- jQuery UI | position() Method
- JQuery | parseHTML() method
- jQuery | css() Method
- jQuery | add() method with Example
- jQuery | not() method with Examples
- jQuery | ajaxStart() Method
- JQuery UI | Progressbar method
- jQuery | get() Method
- jQuery | fadeIn() Method
- jQuery | delegate() Method
- jQuery | outerHeight() Method
- jQuery | event.isDefaultPrevented() Method
- jQuery | outerWidth() Method
- jQuery | before() Method
- jQuery | off() Method
- jQuery | html() Method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

