Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

JavaScript Unable to retrieve blob from SQL database in IE11

  1. Nov 3, 2016 #1

    I am storing a blob in my database running wamp64/MySQL and I am using AJAX to retrieve it. The code works with Chrome, Edge, and FireFox but I obtain the error message "Invalid State Error" in the debugger for the line "xmlhttp.responseType='arraybuffer'" when I run it under IE11. I have used FileReader with responseType='blob' to read the blob but get a similar error so I just took out the FileReader. I've googled the error message but could not figure out how to solve the problem. I was wondering if someone could help me get my code to work with IE11. This is my Javascript:
    Code (Javascript):

           xmlhttp = new XMLHttpRequest();
          xmlhttp.onreadystatechange = function()
            if (this.readyState == 4 && this.status == 200)
              // start type-casting the blob here
    And the PHP code for getImagAlgebraicBlob.php uses PDO and is very simple:


    include 'algebraicFunctionBlobClass.php';

    $blobObj = new algebraicFunctionBlob();

    $a = $blobObj->selectImagBlob(132);

    echo $a['imagWebGLData'];


  2. jcsd
  3. Nov 3, 2016 #2
    It is a bug and it was not fixed for IE11 because it is not within that place's team control. There are no indications of them planning to fix it for that browser. Even on Edge they marked it as NOT REPRODUCIBLE despite it being the most basic example that could be provided.

    You could tell the people visiting your site using those browsers that the site is incompatible due to a very old bug that was not fixed in them and suggest that they use another browser.

    Or you could use jQuery. If you decide to use jQuery, you could try this:
    Code (Javascript):

      method: "POST",
      url: "getImagAlgebraicBlob.php",
      .done(function(returnedResponse ) {
        //Convert 'returnedResponse' into an Uint8Array so that an ArrayBuffer can be used
        theResponse = new Uint8Array(returnedResponse);
        theBlobSize = theResponse.prototype.buffer.byteLength;
    Edit: code comment edited
    Last edited: Nov 3, 2016
  4. Nov 3, 2016 #3


    Staff: Mentor

  5. Nov 3, 2016 #4
    Outstanding guys! Yes, I tried the work-around setting responseType after xhr.open() and it worked. Thanks a bunch guys for helping me with setting up all the pieces to get this software up and running!
  6. Nov 3, 2016 #5
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted