title: Jquery - executing custom function calls in order
body: <p>I'm using jQuery 1.9.1. I have a custom function that does some operations an then performing an $.ajax call. I would like to call this function in sequence. I've tried $.when, but it does not solve my problem.</p>
  
  <pre><code>function func(param) {
      //some operations
      $.ajax()
  }
  
  main() {
      //first call
      func(param1);
      //wait for done and the run the second
      func(param2);
  }
  </code></pre>