0

I would like to do this :

function loadSound(url) {
    var request = new XMLHttpRequest();
    request.open('GET', url, true);
    request.responseType = 'arraybuffer';

    // Decode asynchronously
    request.onload = function() {
        context.decodeAudioData(request.response, function(buffer) {
            sound= buffer;
        }, onError);
    }
    request.send();
}

But I got this error :

Uncaught InvalidAccessError: Failed to set the 'responseType' property on 'XMLHttpRequest': The response type cannot be changed for synchronous requests made from a document.

Any advice?

CubeJockey
  • 2,209
  • 8
  • 24
  • 31
Crocsx
  • 2,534
  • 1
  • 28
  • 50

1 Answers1

1

This is something the specifications define:

Note: Starting with Gecko 11.0 (Firefox 11.0 / Thunderbird 11.0 / SeaMonkey 2.8), as well as WebKit build 528, these browsers no longer let you use the responseType attribute when performing synchronous requests. Attempting to do so throws an NS_ERROR_DOM_INVALID_ACCESS_ERR exception. This change has been proposed to the W3C for standardization.

From: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest

Christian Benseler
  • 7,907
  • 8
  • 40
  • 71