Skip to content

Instantly share code, notes, and snippets.

@ridhotegar
Last active December 23, 2021 05:02
Show Gist options
  • Save ridhotegar/8d796cbd3e280f349be598ecfe14e709 to your computer and use it in GitHub Desktop.
Save ridhotegar/8d796cbd3e280f349be598ecfe14e709 to your computer and use it in GitHub Desktop.
XMLHttpRequest download with JQuery
$.ajax({
url: "https://file-examples-com.github.io/uploads/2017/02/zip_10MB.zip",
cache: false,
xhr: function(){
var xhr = new XMLHttpRequest();
xhr.responseType= 'blob';
xhr.onprogress = e => console.log(`${parseInt((e.loaded/e.total)*100)}%`)
return xhr;
},
success: e => console.log('done')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment