title: javascript objects, callback and this keyword
body: <p>I'm having trouble figuring out how to correctly reference the 'right' 'this' in a jquery ajax callback.</p>
  
  <p>I have a javascript class where I define the callback:</p>
  
  <pre><code>Foo.prototype.onCallback = function(response) {
    // 'this' should refer to an instance of foo in both the following cases
    this.bar(...)    
    this.hello(...)
  }
  </code></pre>
  
  <p>outside of the class I have: </p>
  
  <pre><code>foo1 = new Foo()
  myCallback = foo1.onCallback;
  
  $.ajax({
    ...
    success: function(response) {myCallback(response); ... }
  });
  </code></pre>
  
  <p>Right now I believe 'this' within foo1.onCallback is referring to the html element the ajax call is attached to. How do I ensure that 'this' refers to foo1? Is there a better way to do this?</p>