Skip to content

Instantly share code, notes, and snippets.

@smedstadc
Last active June 1, 2016 19:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smedstadc/ca0f3ded6b3f3c479c66b4793bdbab29 to your computer and use it in GitHub Desktop.
Save smedstadc/ca0f3ded6b3f3c479c66b4793bdbab29 to your computer and use it in GitHub Desktop.
```js
function handleUploadProgress(event) {
//...
}
function handleDownloadProress(event) {
//...
}
function prepareXHR() {
var xhr = new XMLHttpRequest();
xhr.upload.addEventListener("progress", handleProgress, false);
xhr.addEventListener("progress", handleProgress, false);
return xhr;
};
$.ajax({
type: 'POST',
url: url,
data: data,
xhr: prepareXHR
})
.done(handleDone)
.fail(handleFail)
.always(handleAlways);
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment