JQuery deferred.resolve() method - GeeksforGeeks

14 Jul, 2020
This deferred.resolve() method in JQuery is used to resolve a Deferred object and call any doneCallbacks with the given arguments.Syntax:
deferred.resolve([args])

Parameters:
args: This is optional parameters and is arguments which are passed to the doneCallbacks.
Return Value: This method returns the deferred object.
There are two examples discussed below:
Example: In this example, The resolve() is called with the arguments.<!DOCTYPE HTML> <html>  <head>     <title>       JQuery | deferred.resolve() 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.resolve() method";        function Func(val, div){          $(div).append(val);        }        function Geeks() {            var def = $.Deferred();            def.done(Func);            def.resolve('resolve() method is called with arguments            and Deferred object is resolved', '#GFG_DOWN')        }     </script> </body>   </html>             
<!DOCTYPE HTML> <html>  <head>     <title>       JQuery | deferred.resolve() 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.resolve() method";        function Func(val, div){          $(div).append(val);        }        function Geeks() {            var def = $.Deferred();            def.done(Func);            def.resolve('resolve() method is called with arguments            and Deferred object is resolved', '#GFG_DOWN')        }     </script> </body>   </html>             
Output:
Example: In this example, The resolve() is called without arguments.<!DOCTYPE HTML> <html>  <head>     <title>       JQuery | deferred.resolve() 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.resolve() method";        function Func(){          $('#GFG_DOWN').append("resolve() method is called without arguments          and Deferred object is resolved");        }        function Geeks() {            var def = $.Deferred();            def.done(Func);            def.resolve()        }     </script> </body>   </html>
Example: In this example, The resolve() is called without arguments.
<!DOCTYPE HTML> <html>  <head>     <title>       JQuery | deferred.resolve() 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.resolve() method";        function Func(){          $('#GFG_DOWN').append("resolve() method is called without arguments          and Deferred object is resolved");        }        function Geeks() {            var def = $.Deferred();            def.done(Func);            def.resolve()        }     </script> </body>   </html>
Output:
jQuery-Methods
JQuery
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Difference Between JavaScript and jQuery
How to use Anchor tag as submit button ?
jQuery | ajax() Method
How to scroll to specific element using jQuery ?
How to get form data using JavaScript/jQuery?
Express.js express.Router() Function
Installation of Node.js on Linux
How to set input type date in dd-mm-yyyy format using HTML ?
Differences between Functional Components and Class Components in React
How to create footer to stay at the bottom of a Web page?