title: Save response from jQuery ajax function
body: <p>I've got a custom function, which calls ajax request and I'm able to save response data to variable and return it. <strong>0</strong> is always returned, but alert shows e.g. 3712.</p>
  
  <p>Here is the function:</p>
  
  <pre><code>function getNo(index, val) {
  
  var $ret = 0;
  
  $('body').showLoading();
  $.ajax({
      type: 'POST',
      url: BASE_URL + 'tools/no.php?id='+index+'&amp;value='+val,
      data: $("#form").serialize(),
      cache: false,
      success: function(data) {
          $('body').hideLoading();
          alert('data: ' + data);
          $ret = data;
      }
  });
  return $ret;
  }
  </code></pre>