Created
November 30, 2014 17:31
-
-
Save fbeauchamp/12f9a7b0dd08b13a87ba to your computer and use it in GitHub Desktop.
downlod with progress
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
function transferComplete() { | |
} | |
function stateChange() { | |
contentSize = this.getResponseHeader('X-Content-size');//nginx se charge de la compression gzip et mange le content-size | |
} | |
function updateProgress(evt) { | |
filtered_operations.trigger('loadProgress', evt.loaded, contentSize) | |
} | |
function failed(evt) { | |
} | |
filtered_operations.trigger('loadStart') | |
var xhr = new XMLHttpRequest(); | |
xhr.addEventListener('readystatechange', stateChange, false); | |
xhr.addEventListener("progress", updateProgress, false); | |
xhr.addEventListener("load", transferComplete, false); | |
xhr.addEventListener("error", failed, false); | |
xhr.addEventListener("abort", failed, false); | |
xhr.open("get", url true); | |
xhr.send(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment