Last active
December 31, 2015 20:09
-
-
Save HerrPi/8038159 to your computer and use it in GitHub Desktop.
Load the first 5 bytes of a file with a jQuery ajax request. Beforehand, check whether the Range header is supported.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function () { | |
$.ajax({ | |
success: function (data, status, jqxhr) { | |
if (jqxhr.getResponseHeader("Accept-Ranges") == "bytes") { | |
$.ajax({ | |
headers: { | |
"Range": "bytes=0-4" | |
}, | |
success: function (data) { | |
$("pre").text(data); | |
}, | |
type: "GET", | |
url: "some_local_file" | |
}); | |
} else { | |
alert("Range header not supported."); | |
} | |
}, | |
type: "HEAD", | |
url: "some_local_file" | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment