Bug Tracker

Changes between Initial Version and Version 2 of Ticket #9992


Ignore:
Timestamp:
Aug 7, 2011, 10:45:58 AM (12 years ago)
Author:
jaubourg
Comment:

Maybe it could be implemented using a "text bin" converter. You'd need a prefilter for bin requests to add responseType: "arraybuffey" into options.xhrFields though. And that's provided xhr.responseText === xhr.response which I'm really not sure about.

So, this may require changes in the xhr transport... but I'm unsure if this is already "standard" enough (ie. not requiring insane jumping through hoops).

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #9992

    • Property Cc jaubourg added
    • Property Priority changed from undecided to low
    • Property Component changed from unfiled to ajax
  • Ticket #9992 – Description

    initial v2  
    11it would be nice if we could get "arraybuffer" or "blob" response type from ajax request.[[BR]]
    2 it seems direct "blob" response is not yet supported by all browser (chrome don't) but we can easily build it from arraybuffer:[[BR]]
    3 
    4 var xhr=new XMLHttpRequest();[[BR]]
    5 xhr.open("GET",url,true);[[BR]]
    6 xhr.responseType="arraybuffer";[[BR]]
    7 xhr.onload=function(){[[BR]]
    8     if (this.status==200){[[BR]]
    9         var bb=new BlobBuilder();[[BR]]
    10         bb.append(this.response);[[BR]]
    11         var blob=bb.getBlob());[[BR]]
    12         ...[[BR]]
    13     }[[BR]]
    14 };[[BR]]
     2it seems direct "blob" response is not yet supported by all browser (chrome don't) but we can easily build it from arraybuffer:
     3{{{#!js
     4var xhr=new XMLHttpRequest();
     5xhr.open("GET",url,true);
     6xhr.responseType="arraybuffer";
     7xhr.onload=function(){
     8    if (this.status==200){
     9        var bb=new BlobBuilder();
     10        bb.append(this.response);
     11        var blob=bb.getBlob());
     12        //...
     13    }
     14};
    1515xhr.send();
     16}}}