Monday, 26 August 2013

jQuery Ajax - downloading incomplete (binary) file

jQuery Ajax - downloading incomplete (binary) file

This is what I have:
jquery/1.10.2
$.ajax({
url: "http://samplepdf.com/sample.pdf",
dataType: "text",
data: "",
success: function(data) {
alert(data.length);
},
error: function(a, b, c) {}
});
When I run that locally (in Safari 6.0.5 on OS X), I get 211300. However,
the actual file appears to be 218882 bytes. With something fully ASCII
(such as http://www.angio.net/pi/digits/pi1000000.txt), it seems to work
correctly.
I don't need to download the file, but rather, work with its content.
Is there any way to make ajax work with binary files (either client side
or server side) without resorting to using base64?

No comments:

Post a Comment