jQuery deferred.resolveWith() Method Last Updated : 07 Aug, 2024 Comments Improve Suggest changes Like Article Like Report 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 parameter that are passed to the doneCallbacks. Return ValueThis method method returns the deferred object. Example: In this example, we resolve the Deferred object with two arguments and process any doneCallbacks. HTML <!DOCTYPE HTML> <html> <head> <title> jQuery deferred.resolveWith() 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> <h2>jQuery deferred.resolveWith() Method</h2> <button onclick="myFunction();"> click here </button> <p id="result"></p> <script> function Func(val, div) { $(div).append(val); } function myFunction() { let def = $.Deferred(); def.done(Func); def.resolveWith( this, ['Deferred is Resolved by resolveWith() Method', '#result'] ); } </script> </body> </html> Output Example: In this example, we resolve the Deferred object with only one arguments and process any doneCallbacks. HTML <!DOCTYPE HTML> <html> <head> <title> jQuery deferred.resolveWith() 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> <h2>jQuery deferred.resolveWith() Method</h2> <button onclick="myFunction();"> Click Here </button> <p id="result"></p> <script> function Func(div) { $(div).append( 'Deferred is resolved by resolveWith() method'); } function myFunction() { let def = $.Deferred(); def.done(Func); def.resolveWith(this, ['#result']); } </script> </body> </html> Output Comment More infoAdvertise with us Next Article jQuery deferred.resolveWith() Method P PranchalKatiyar Follow Improve Article Tags : JavaScript Web Technologies JQuery jQuery-Methods Similar Reads JQuery deferred.resolve() method This deferred.resolve() method in JQuery is used to resolve a Deferred object and call any doneCallbacks with the given arguments. Syntaxdeferred.resolve([args])Parametersargs: This is optional parameters and is arguments which are passed to the doneCallbacks. Return ValueThis method returns the def 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.reject() Method The deferred.reject() method in jQuery is used to reject a Deferred object and call any failCallbacks with the given arguments.Syntax:deferred.reject( [args] )Parameters:args: It is an optional parameter that are passed to the failCallbacks.Return Value: This method returns the deferred object.Examp 1 min read JQuery deferred.notifyWith() method 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: 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 Like