Ticket #9992 (closed feature: patchwelcome)
$.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
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).
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

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