title: Set variable outside AJAX request
body: <p>I'm attempting to create an ajax function that returns a specific string from a page, and then sets it in the class I created. However, when I attempt to call <code>this.setGlideUser</code> within the ajax success parameter, it tells me that the </p>
  
  <pre><code>object has no function setUserGlide.
  </code></pre>
  
  <p>And when I attempt to call <code>this.setUserGlide</code> outside of the success parameter, and then look at the value of <code>_glideUser</code>, <code>_glideUser</code> is undefined. Here is a snippet of my code. </p>
  
  <pre><code>function main()
  {
      this.start = true;
  }
  
  main.prototype.load = function()
  {
      var _glideUser;
      $.ajax(
      {
          url: '/home',
          dataType: 'text',
          success: function(data)
          {
              // Truncated
              _glideUser = unescape(data).match(pattern);
          }
      });
      this.setGlideUser(_glideUser);
      return 1;
  }
  
  main.prototype.setGlideUser(user)
  {
      return this._glideUser = user;
  }
  
  main.prototype.getGlideUser()
  {
      return this._glideUser;
  }
  
  var _main = new main();
  _main.load();
  // check that the ajax has completely loaded
  _main.getGlideUser(); // returns undefined
  </code></pre>
  
  <p>I can't think of a way to set the <code>_glideUser</code> variable within the main class from the Ajax success function. I would like to get the value of <code>_glideUser</code> within another function, to do things with it. Any suggestions? </p>