Open In App
Related Articles

JQuery deferred.resolve() method

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report
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
    </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
    </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:


Last Updated : 14 Jul, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads