title: Assigning variable from jquery ajax call returns undefined
body: <p>I am new to jquery and I am trying to assign a value to a variable after an ajax call but it returns undefined. My code is below:</p>
  
  <pre><code>function prepareDocument() {
  var a = getAverageRating(1);
  alert(a);
  }
  function getAverageRating(pageId) {
  $.ajax({
      url: "../services/rating.ashx?action=getAverageRating&amp;pageId=" + pageId,
      dataType: "text",
      type: "GET",
      data: {},
      error: function (err) {
          displayDialogBox("Error", err.toString());
      },
      success: function (data) {
          return data;
      }
  });
  }
  </code></pre>
  
  <p>Any help would be appreciated. 
  Thanks,</p>