Opened 11 years ago
Closed 11 years ago
#9992 closed feature (patchwelcome)
$.get binary
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | low | Milestone: | None |
Component: | ajax | Version: | 1.6.2 |
Keywords: | Cc: | jaubourg | |
Blocked by: | Blocking: |
Description (last modified by )
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 (3)
comment:1 Changed 11 years ago by
Cc: | jaubourg added |
---|---|
Component: | unfiled → ajax |
Priority: | undecided → low |
comment:2 Changed 11 years ago by
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 11 years ago by
Resolution: | → patchwelcome |
---|---|
Status: | new → closed |
Sounds like this should start life as a converter, outside core. If it's popular we can incorporate it.
I think this is best implemented with a converter, but I'll defer to jaubourg.