Skip to content
Related Articles

Related Articles

JQuery deferred.resolve() method
  • Last Updated : 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
    </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:

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.




My Personal Notes arrow_drop_up
Recommended Articles
Page :