# JavaScript Unable to retrieve blob from SQL database in IE11

1. Nov 3, 2016

### aheight

Hi,

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.responseType='arraybuffer';

{
if (this.readyState == 4 && this.status == 200)
{
theResponse=this.response;
theBlobSize=theResponse.byteLength;

// start type-casting the blob here
}
}
xmlhttp.open("POST","getImagAlgebraicBlob.php",true);
xmlhttp.send();

And the PHP code for getImagAlgebraicBlob.php uses PDO and is very simple:

PHP:
<?php

include 'algebraicFunctionBlobClass.php';

$blobObj = new algebraicFunctionBlob();$a = $blobObj->selectImagBlob(132); echo$a['imagWebGLData'];

?>

2. Nov 3, 2016

### Psinter

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):

\$.ajax({
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
3. Nov 3, 2016

4. Nov 3, 2016

### aheight

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!

5. Nov 3, 2016