title: JQuery AJAX response undefined
body: <p>I have a strange (probably not for some I would wager) problem, I have a JavaScript method to call all of my ajax calls, please see below.</p>
  
  <pre><code>function ajaxCall(url, params) {
  if (params === null) {
      $.ajax({
          type: 'POST',
          url: url,
          contentType: 'application/json; charset=utf-8',
          dataType: 'json'
      }).success(function(response) {
          return response;
      }).error(function(response) {
          return response;
      });
  } else {
      var data = JSON.stringify(params);
      $.ajax({
          type: 'POST',
          url: url,
          data: data,
          contentType: 'application/json; charset=utf-8',
          dataType: 'json'
      }).success(function(response) {
          return response;
      }).error(function(response) {
          return response;
      });
    }
  }
  </code></pre>
  
  <p>when I call this method I get the appropriate response from the AJAX call and all looks rosy, until I return the response the call is returned undefined?</p>
  
  <p>for completeness I will include my call code.</p>
  
  <pre><code>var call = ajaxCall(someUrl, someParams);
  </code></pre>
  
  <p>just to clarify and make sure my ramblings are understood <strong>call</strong> would be undefined in the above example? </p>