title: jQuery.ajax: "An attempt was made to use an object that is not, or is no longer, usable"
body: <p>I'm trying to read some binary data from the server, and it works fine this way: </p>
  
  <pre><code>var xml = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("MSXML2.XMLHTTP");
  
  xml.open("GET", "/some.php", true);
  xml.responseType = "arraybuffer";
  
  xml.onreadystatechange = myHandler; // myHandler here seems to be irrelevant
  
  xml.send();
  </code></pre>
  
  <p>However if I try to do the same thing with jquery like this:</p>
  
  <pre><code>$.ajax({
      url: "/some.php",
      xhrFields: {
          responseType: "arraybuffer"
      },
      complete: function(xhr) {
          console.log(xhr.readyState);
          console.log(xhr.statusText); // is: [Exception... "An attempt was made to use an object that is not, or is no longer, usable"  code: "11" nsresult: "0x8053000b (InvalidStateError)" ...
      }
  });
  </code></pre>
  
  <p>I can't get the results in <code>myHandler</code>, since it's returning with an error "An attempt was made to use an object that is not, or is no longer, usable" on this <a href="https://github.com/jquery/jquery/blob/master/src/ajax/xhr.js#L85" rel="nofollow">line in jquery source</a> - apparently <code>xhr</code> is no longer usable at that point. What's the best way to handle this?</p>
  
  <p>It's actually the same on stackoverflow: go to /, type this in firebug console:</p>
  
  <pre><code>$.ajax({
          url: "/",
          xhrFields: {
              responseType: "arraybuffer"
          },
          complete: function(xhr) {
              console.log(xhr.readyState);
              console.log(xhr.statusText);
          }
      });
  </code></pre>