title: ajax call back JSON object returns undefined
body: <p>I have looked at many many posts about this subject and have tried several of the solutions but i can not seem to get it right.</p>
  
  <p>last attempt</p>
  
  <pre><code>function checkzip(x){  
  
         $.ajax({
         type:'POST',
         url:'zipcheck.php',
         data:{zip: x},
         async: false
      }).done(function(r){
          rates(r);
      });
  }
  
  function rates(r){
      alert (r);
      if (r !== 'none'){
      m = JSON.parse(r);
      return m;
      }
      else {
          return false;
      }
  }
  </code></pre>
  
  <p>json being returned is {"rateA":"125","rateB":"80","rateC":"150","rateD":"130"}</p>
  
  <p>so i want to be able to:</p>
  
  <pre><code>new_rate = checkzip('77090');
  </code></pre>
  
  <p>and</p>
  
  <pre><code>alert (new_rate.rateA);
  </code></pre>
  
  <p>but I am getting undefined for the returned value</p>
  
  <p>I have tried passing the function in the success: AND .done(), i have tried returning it directly from both instead of passing to a separate function as well while setting async: false.
  I have tried placing the ajax call withing a function inside the zipcheck() function and then calling it from within there as well.
  I am missing something along the lines of creating an object from ajax or working with asynchronous functions.</p>