title: Assigning scope amongst jQuery.getJSON and a JS.Class
body: <p>I'm trying to assign some JSON data to a property of a <a href="http://jsclass.jcoglan.com/" rel="nofollow noreferrer">JS.Class</a> instance.</p>
  
  <pre><code>var MyClass = new JS.Class({
    initialize: function(uuid) {
        this.uuid = uuid;
    },
    write: function() {
      $.getJSON(url+"?callback=?", {}, function(data) {
        Assign(data);
      });
      function Assign(data) { this.content = data; };
    }
  });
  
  var m = new MyClass("uuid_goes_here");
  m.write();
  </code></pre>
  
  <p>The JSON is received asynchronously, which is why there's a function call within the <code>$.getJSON</code> callback.</p>
  
  <p>The problem I have now is that the <code>this.content</code> within the <code>Assign</code> function is not within the scope of the instance method named <code>write</code>.  So whereas <code>this.uuid</code> returns correctly, <code>this.content</code> remains undefined (as you would expect).</p>
  
  <p>Any ideas on how to correct this?  I've tried using a global variable as a workaround but the async call doesn't allow for that (plus it's a crappy solution).</p>
  
  <p>Some points to note, in case they matter: I have to use JSONP, so the "?callback=?" has to stay, and I'd like to keep it async.</p>