title: Do action after another ajax function ends
body: <p>I'm searching a solution for this:
  I have a function that updates the content of a table in my application.</p>
  
  <pre><code>function prev_update(cli_id){
      $("#list").empty();
      $("#list").append("&lt;tr&gt;&lt;td colspan=11&gt;&lt;img src='images/loading.gif' alt=loading title=loading /&gt;&lt;/td&gt;&lt;/tr&gt;");
      $.ajax({
          type        : 'POST',
          url         : 'json/get.php?t=2&amp;id='+cli_id, 
          dataType    : 'json',
          encode      : true
      })
      .done(function(data) {
          $("#list").empty();
          if ((data)["prev_list"]) {  
              $.each((data)["prev_list"], function( i, val ) {
                  $( "#list" ).append(val);
              });
              $("#edit").hide("slow");
          } else {
              $("#list").append("&lt;tr&gt;&lt;td colspan=11&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;");                       
          }
      });
  };
  </code></pre>
  
  <p>In another function I'm updating a row of a table, when I finish to edit the content of a row of the table i launch a similar function but in the .done row I call the prev_update function and AFTER this is finished I have to push a button in the updated table content, for review the modifications...
  Here's the code:</p>
  
  <pre><code>$("#prev_mod").on("click",(function( event ) {
       $('#loading_img').css('display','inline');
       header_print();
       $.ajax({
           type       : 'POST',
           url        : 'json/post.php?mod='+$('#prev_id').val(),
           data       : $("#form_sog").serialize(),
           dataType   : 'json',
           encode : true
     })
     .done(function(data) {
          if ((data)["success"]===false) {    
              $('#form_edit').hide('slow');
              prev_update();
              $('#edit_'+$('#prev_id').val()).click();
          });
     });
  }));
  </code></pre>
  
  <p>I have to wait when prev_update() function ends then click the button because the button is in the table that is updating.
  I tried to use also deferred object but it doesn't works (maybe for my error).
  I can't edit the function prev_update because it's used by other functions.</p>