title: building a simple ajax class in javascript
body: <p>I am trying to make a simple ajax class for a chrome extension. I get an undefined error  <code>Uncaught TypeError: Cannot read property 'readyState' of undefined</code> when I try to run the code. What seems to cause this issue?</p>
  
  <pre><code>function ajax(arguments, callback) {
      this.xhr = new XMLHttpRequest();
      this.xhr.open(arguments.requestType, arguments.requestUrl + arguments.requestParameters, true);
      this.xhr.onreadystatechange = function() {
          if (this.readyState === 4 &amp;&amp; this.status === 200) {
              requestedData = JSON.parse(this.responseText);
              callback(requestedData);
          }
      }
      this.xhr.send();
  }
  
  var ajaxRequest = new ajax({ 
      requestType: 'GET',
      requestUrl: 'http://ezswag.com/bots/terms.php',
      requestParameters: ' ',
      }, function(json) {
          //console.log(json);  =&gt; json {apple: "red", cheery: "red"}
          return json;
      });
  
      console.log(ajaxRequest);
  </code></pre>
  
  <p><strong>(Updated code, and working</strong>)</p>