title: Javascript: Setting class property from ajax success
body: <p>I have a "class"/function called Spotlight. I'm trying to retrieve some information through ajax and assign it to a property of Spotlight. Here is my Spotlight class:</p>
  
  <pre><code>function Spotlight (mId,mName) {
      this.area = new Array();
  
      /**
       * Get all area information
       */
      this.getArea = function () {
  
          $.ajax({
              url: base_url +'spotlight/aGetArea',
              type: 'POST',
              success: function (data) {
                  this.area = data;
              }
          });
      }
  }
  </code></pre>
  
  <p>I have assigned the object to an array, and it would be difficult to get to it from within Spotlight, so I'm hoping to access everything using 'this.' It appears though that the success function is outside of the class, and I don't know how to make it inside the class.</p>
  
  <p>Is there a way to get the data into the class property using this.area rather than Spotlight.area?</p>