title: How to get XMLHttpRequest responseText while using .bind in Javascript?
body: <p>This is what I would LIKE to do:</p>
  
  <pre><code>response: string;
  sendCreateInvoice(invoice, job){
    let url = 'assets/php/myScript.php';
    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function() {
      if (this.readyState == 4 &amp;&amp; this.status == 200) {
        this.response = this.responseText;
      };
    };
    xmlhttp.open('POST', url, true);
    xmlhttp.send(invoice);
  }
  </code></pre>
  
  <p>so I THINK I need to use <code>.bind(this)</code> but when I do that I can't seem to access <code>this.responseText</code> anymore. I tried like this:</p>
  
  <pre><code>response: string;
  sendCreateInvoice(invoice, job){
    let url = 'assets/php/myScript.php';
    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function() {
      if (this.readyState == 4 &amp;&amp; this.status == 200) {
        this.response = this.responseText;
      };
    }.bind(this);
    xmlhttp.open('POST', url, true);
    xmlhttp.send(invoice);
  }
  </code></pre>
  
  <p>And I tried <code>this.xmlhttp.responseText</code> and <code>xmlhttp.responseText</code> but no luck. Where am I going wrong? How can I save the <code>responseText</code> to <code>response</code>?</p>
  
  <p>==================</p>
  
  <p>Working code:</p>
  
  <pre><code>response: string;
  sendCreateInvoice(){
    let url = 'assets/php/myScript.php';
    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = () =&gt; {
      if (xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status == 200) {
        this.response = xmlhttp..responseText;
      };
    };
    xmlhttp.open('POST', url, true);
    xmlhttp.send(invoice);
  }
  </code></pre>