JavaScript class function this operator
<p>I have a JS class that contains a AJAX post. I'm trying to refer to the class members from within the post function using <code>this</code> but it doesn't seem to be working. </p>

<p>For example, from this: </p>

<pre><code>function Classy() {

  this.goal = 0;

  $.post(   
    "class/initial.php",
    function(back) {                
        this.goal = back.goal;  
  }, "json");       

  this.SampleFunction = function() {
    alert(this.goal);   
  }
}

tester = new Classy();
tester.SampleFunction();
</code></pre>

<p>The alert box outputs a value of <code>0</code>, even though this is definitely not what is coming back from the php file. I think the issue is I need something other than <code>this</code> to refer to the parent class. Anyone have any ideas?</p>
