title: 'this' is undefined in JavaScript class methods
body: <p>I'm new to JavaScript. New as far as all I've really done with it is tweaked existing code and wrote small bits of jQuery.</p>
  
  <p>Now I'm attempting to write a "class" with attributes and methods, but I'm having trouble with the methods. My code: </p>
  
  <pre><code>function Request(destination, stay_open) {
      this.state = "ready";
      this.xhr = null;
      this.destination = destination;
      this.stay_open = stay_open;
  
      this.open = function(data) {
          this.xhr = $.ajax({
              url: destination,
              success: this.handle_response,
              error: this.handle_failure,
              timeout: 100000000,
              data: data,
              dataType: 'json',
          });
      };
  
      /* snip... */
  
  }
  
  Request.prototype.start = function() {
      if( this.stay_open == true ) {
          this.open({msg: 'listen'});
      } else {
  
      }
  };
  //all console.log's omitted
  </code></pre>
  
  <p>The problem is, in <code>Request.prototype.start</code>, <code>this</code> is undefined and thus the if statement evaluates to false. What am I doing wrong here? </p>