title: Javascript When and Done Function use
body: <p>I am trying to call two different functions in third function but one after the other.One function has ajax call, whose values are used in other function. it is step by step process. I don't want to use one into the other.</p>
  
  <pre><code>function f1()
  {
      // ajax call 
      return r1
  }
  
  function f2(r2)
  {
      // do some of the work based on r2
  }
  
  function f3()
  {
      $.when(f1()).done(function(data){
              f2(data)
  
      });
  }
  </code></pre>
  
  <p>I also tried with $.when().then(); but still of no use.</p>
  
  <p>Thanks, in advance. </p>
  
  <p>UPDATE :- Below is the answer for my Question based on solution provide by @dreamweiver. </p>
  
  <pre><code>var json_data = '';
  function f1()
  {
  
      $.ajax({
           url: "test.php",
           method: "POST",
           async : false,
           data: { },
           success:function(data){
              json_data = eval(data);
           }
  
         });  
  
  
  }
  
  function f2(t)
  {
  
      console.log("values is "+t);
  }
  
  function f3()
  {
      $.when(f1()).done(function(){
          f2(json_data);
     });
  }
  </code></pre>
  
  <p>Thanks everyone for your feedbacks.</p>