jpillora / xdomain

A pure JavaScript CORS alternative
https://jpillora.com/xdomain/
3.12k stars 269 forks source link

Bug: Preloading images causes XMLHttpRequest TypeError. #136

Closed dannycampa closed 9 years ago

dannycampa commented 9 years ago

Hello,

First I'd like to say your plugin saves our people a lot of time.

I'm having an issue with 0.6.17 when I try to preload some PNG images.

Uncaught InvalidStateError: Failed to read the 'responseText' property from 'XMLHttpRequest': The value is only accessible if the object's 'responseType' is '' or 'text' (was 'arraybuffer').

Over on line 298:

readBody = function() {
    if ('responseText' in xhr) {
      response.text = xhr.responseText;
    }
    if ('responseXML' in xhr) {
      response.xml = xhr.responseXML;
    }
    if ('response' in xhr) {
      response.data = xhr.response;
    }
  };

I'm assuming you just need to add a condition inside to look for an arraybuffer instead of text.

Please let me know if this is enough information for you to take care of this. If you need to see it in action I'll need to set up a staging area for you to see it. I rolled back to 0.6.15 on my production site to resolve the issue for now.

Thanks again for your work!

jpillora commented 9 years ago

Thanks for the bug report, will take a look into it soon

On Saturday, February 21, 2015, dannycampa notifications@github.com wrote:

Hello,

First I'd like to say your plugin saves our people a lot of time.

I'm having an issue with 0.6.17 when I try to preload some PNG images.

Uncaught InvalidStateError: Failed to read the 'responseText' property from 'XMLHttpRequest': The value is only accessible if the object's 'responseType' is '' or 'text' (was 'arraybuffer').

Over on line 298:

readBody = function() { if ('responseText' in xhr) { response.text = xhr.responseText; } if ('responseXML' in xhr) { response.xml = xhr.responseXML; } if ('response' in xhr) { response.data = xhr.response; } };

I'm assuming you just need to add a condition inside to look for an arraybuffer instead of text.

Please let me know if this is enough information for you to take care of this. If you need to see it in action I'll need to set up a staging area for you to see it. I rolled back to 0.6.15 on my production site to resolve the issue for now.

Thanks again for your work!

— Reply to this email directly or view it on GitHub https://github.com/jpillora/xdomain/issues/136.

jpillora commented 9 years ago

Merging across from XHook into XDomain now...