Bug Tracker

Modify

Ticket #9992 (closed feature: patchwelcome)

Opened 23 months ago

Last modified 22 months ago

$.get binary

Reported by: sfornengo@… Owned by:
Priority: low Milestone: None
Component: ajax Version: 1.6.2
Keywords: Cc: jaubourg
Blocking: Blocked by:

Description (last modified by jaubourg) (diff)

it would be nice if we could get "arraybuffer" or "blob" response type from ajax request.
it seems direct "blob" response is not yet supported by all browser (chrome don't) but we can easily build it from arraybuffer:

var xhr=new XMLHttpRequest();
xhr.open("GET",url,true);
xhr.responseType="arraybuffer";
xhr.onload=function(){
    if (this.status==200){
        var bb=new BlobBuilder();
        bb.append(this.response);
        var blob=bb.getBlob());
        //...
    }
};
xhr.send();

Change History

comment:1 Changed 23 months ago by timmywil

  • Cc jaubourg added
  • Priority changed from undecided to low
  • Component changed from unfiled to ajax

I think this is best implemented with a converter, but I'll defer to jaubourg.

comment:2 Changed 23 months ago by jaubourg

  • Description modified (diff)

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).

comment:3 Changed 22 months ago by dmethvin

  • Status changed from new to closed
  • Resolution set to patchwelcome

Sounds like this should start life as a converter, outside core. If it's popular we can incorporate it.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.