jQuery deferred.done() Method

This deferred.done() method in jQuery is used to add handlers which are to be called when the deferred object is resolved.

Syntax: 

deferred.done(Callbacks [, Callbacks])

Parameters:

  • Callbacks: This parameter specifies a function, or array of functions, which are called when the Deferred is resolved.
  • Callbacks: This parameter specifies an optional additional functions, or arrays of functions, which are called when the Deferred is resolved. 
     

Return Value: This method returns the deferred object.

Example 1: 



html

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE HTML>
<html>
  
<head>
    <script src=
    </script>
</head>
  
<body style="text-align:center;">
    <h1 style="color:green;">
        GeeksForGeeks
    </h1>
      
    <p>
        JQuery | deferred.done() method
    </p>
  
    <button onclick="Geeks();">
        click here
    </button>
      
    <script>
        function Geeks() {
            $.get("testingGFG.php").done(function () {
                alert("$.get succeessfully completed!");
            });
        
    </script>
</body>
  
</html>

chevron_right



Output:

  • Before clicking on button:

  • After clicking on button:

Example 2:

html

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE HTML>
<html>
  
<head>
    <script src=
    </script>
</head>
  
<body style="text-align:center;">
    <h1 style="color:green;">
        GeeksForGeeks
    </h1>
      
    <p>
        JQuery | deferred.done() method
    </p>
  
    <button onclick="Geeks();">
        click here
    </button>
  
    <p id="GFG_DOWN"></p>
  
      
    <script>
        var el_down = document
                .getElementById("GFG_DOWN");
        function Geeks() {
            $.get("testingGFG.php")
                    .done(function () {
                el_down.innerHTML = 
                "$.get succeessfully completed";
            });
        
    </script>
</body>
  
</html>

chevron_right


Output:




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

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.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.