title: Wait for AJAX before continuing through separate function
body: <p>Alright... at 2am, this is where I draw the line. Help... before my laptop ends up going out the window. :)</p>
  
  <p>I've tried using setTimer, callbacks, and everything else I can think of (along with a few other Stackoverflow hints of course). I've stripped out everything so I'm leaving just the base code.</p>
  
  <p>What I'm looking to do is call parseRow() and before it saves the record at the end, I need to grab the associated Category (via AJAX); however, it blows right past it so category is always "undefined".</p>
  
  <pre><code>function parseRow(row){
      var rowArray     = row.trim().split(",");
      var date         = rowArray[0];
      var checknum     = rowArray[1];
      var payee        = rowArray[2];
      var memo         = rowArray[3];
      var amount       = rowArray[4];
  
      //ERROR: blows right past this one and sets the category variable BEFORE ajax returns
      var category = autoSelectCategory(payee);
  
      saveRecord(date, checkNum, payee, memo, category, payment, deposit);
  }
  
  function autoSelectCategory(payee) {
      var data;
      $.ajax({
          async: false,
          url: "autoselectcategory",
          dataType: "json",
          data: {
              string: payee
          },
          success: function (returnedData) {
              data = returnedData;
          }
      });
      return data;
  }
  </code></pre>