title: How to use "jQuery.when" inside a jQuery ajax success callback?
body: <p>How to use <code>jQuery.when(..).done()</code> inside an Ajax success callback?</p>
  
  <p><strong>Javascript</strong></p>
  
  <pre><code>button = function () {
      doPost('sucess.php',
          'first=' + first,
          function (response) {
              $.when($.ajax("sucess.php")).done(function (a1) { 
                  // Stop the  button function execution 
              });
          }
      );
  }
  doPost = function (url, data, success, complete, options) {
      var defaults = {
          url:url,
          data:data,
          success:success,
          complete:complete,
          type:'POST',
          processData:false
      };
      if (options) {
          for (var i in options) {
              defaults[i] = options[i];
          }
      }
      $.ajax(defaults);
  }
  </code></pre>
  
  <p>Above code doesn't works for some reasons.
  Please see that anything went wrong with  my <code>$.when(..).done()</code> statement.</p>