title: ajax return value
body: <p>I'm having a nightmare trying to do this.
  I must have tried about 15 different methods so far from different posts I've read but all have failed.</p>
  
  <p>I am just trying to get a return value from an ajax post.
  Here is my code</p>
  
  <pre><code>var test = compareNew(this.name, "remove");
  alert(test);
  
  function compareNew(obj, action) {
    $.ajax({
      url: "AJAX_compare_server.php",
      type: 'post',
      data: {
        compare_id:  obj,
        action:   action
      },
        success: function (result) {
        var myObject = eval("(" + result + ")");
        alert(myObject.html);
        return(result);
      }
    });
  }
  </code></pre>
  
  <p>The alert(myObject.html); correctly shows me the html returned but the alert(test); shows me 'undefined'.
  I've spent hours on this but can't figure it out.
  Can you see what I'm missing?</p>