diff options
author | Stephane Desneux <stephane.desneux@iot.bzh> | 2016-05-31 18:16:48 +0200 |
---|---|---|
committer | Stephane Desneux <stephane.desneux@iot.bzh> | 2016-05-31 18:16:48 +0200 |
commit | 5b1e6cc132f44262a873fa8296a2a3e1017b0278 (patch) | |
tree | 43b2cd54e2e300b399ff3f2af4458a2c4ed8a144 /afb-client/bower_components/jszip/documentation/examples/get-binary-files-ajax.html | |
parent | f7d2f9ac4168ee5064580c666d508667a73cefc0 (diff) | |
parent | 85ace9c1ce9a98e9b8a22f045c7dd752b38d9129 (diff) |
Merge afb-client
Diffstat (limited to 'afb-client/bower_components/jszip/documentation/examples/get-binary-files-ajax.html')
-rw-r--r-- | afb-client/bower_components/jszip/documentation/examples/get-binary-files-ajax.html | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/afb-client/bower_components/jszip/documentation/examples/get-binary-files-ajax.html b/afb-client/bower_components/jszip/documentation/examples/get-binary-files-ajax.html new file mode 100644 index 0000000..ee7594e --- /dev/null +++ b/afb-client/bower_components/jszip/documentation/examples/get-binary-files-ajax.html @@ -0,0 +1,43 @@ +--- +title: "Get a file with an ajax call" +layout: default +section: example +--- + +<p>Tip : check the source of the page !</p> + +<h3>With JSZipUtils</h3> +<div id="jszip_utils"></div> + +<script type="text/javascript"> +(function () { + + function showError(elt, err) { + elt.innerHTML = "<p class='alert alert-danger'>" + err + "</p>"; + } + + function showContent(elt, type, content) { + elt.innerHTML = "<p class='alert alert-success'>loaded ! (as a " + type + ")<br/>" + + "Content = " + content + "</p>"; + } + + //========================= + // JSZipUtils + //========================= + JSZipUtils.getBinaryContent('{{site.baseurl}}/test/ref/text.zip', function(err, data) { + var elt = document.getElementById('jszip_utils'); + if(err) { + showError(elt, err); + return; + } + + try { + var zip = new JSZip(data); + showContent(elt, "" + data, zip.file("Hello.txt").asText()); + } catch(e) { + showError(elt, e); + } + }); + +})(); +</script> |