XMLHttpRequest responseType does not work for non-IE browsers

Asked 1 years ago, Updated 1 years ago, 20 views

IE works fine and displays images.
However, if you use a non-IE browser (Firefox, Safari), it stops at the 止まりrequest.responseType=rarraybuffer; ; section, and the rest of the sentence does not work.
If you comment out this part, you will be able to move.

In the case of Firefox, it was mentioned that the responseType must be specified after the open, but it still doesn't seem to work.
What's the problem?

var request=new XMLHttpRequest();
request.onload=function(){
  if(request.status==200){
    var blob = new Blob ([request.response], {type: 'image/gif'});
    document.getElementById('img').src=window.URL.createObjectURL(blob);
  }
};
request.open('GET', picture_name, false);
request.responseType="arraybuffer";
request.send();

javascript

2022-09-30 11:24

1 Answers

Firefox 11 now has an error when using responseType in a synchronization request (request with the third argument request.open false).

Removed support for using XMLHttpRequest responseType and withCredentials attributes when executing synchronization requests.Attempting to use the property results in an NS_ERROR_DOM_INVALID_ACCESS_ERR exception.This change was proposed to W3C for standardization.

Firefox11 for developers-Mozilla|MDN

Try changing the third argument of request.open to true.


2022-09-30 11:24

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.