Unable to retrieve blob from SQL database in IE11

  • JavaScript
  • Thread starter aheight
  • Start date
  • Tags
    Database Sql
In summary, the code works with Chrome, Edge, and FireFox but gets an "Invalid State Error" message in the debugger when run under IE11. The code could be fixed by adding a call to xhr.open() before setting responseType, but that is not necessary.
  • #1
aheight
321
109
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:
JavaScript:
       xmlhttp = new XMLHttpRequest();
 
       xmlhttp.responseType='arraybuffer';
 
      xmlhttp.onreadystatechange = function()
      {
        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'];

?>
 
Technology news on Phys.org
  • #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:
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:
  • Like
Likes harborsparrow and aheight
  • #3
  • Like
Likes QuantumQuest, Psinter and aheight
  • #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!
 

What is causing the error "Unable to retrieve blob from SQL database in IE11"?

There could be multiple reasons for this error, such as a connectivity issue, incorrect SQL query, or browser compatibility issues.

How can I fix the error "Unable to retrieve blob from SQL database in IE11"?

The first step would be to check your database connection and ensure that it is working properly. Next, verify that your SQL query is correct and that there are no syntax errors. If the issue persists, try using a different browser or updating your IE11 to the latest version.

Why is the error "Unable to retrieve blob from SQL database in IE11" specifically occurring in IE11?

This error may be occurring in IE11 due to compatibility issues with the browser. IE11 has limited support for modern web standards and may not be able to handle certain types of data retrieval from a SQL database.

Is there a workaround for the error "Unable to retrieve blob from SQL database in IE11"?

One possible workaround is to use a different browser that has better compatibility with modern web standards. Alternatively, you can try using a different method for retrieving the blob data from the SQL database, such as using a server-side script or API.

How can I prevent the error "Unable to retrieve blob from SQL database in IE11" from happening in the future?

To prevent this error, it is important to regularly update your browser to the latest version and ensure that your HTML, CSS, and JavaScript code are written according to modern web standards. It is also crucial to properly test your code in different browsers before deploying it to a production environment.

Back
Top