JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://unpkg.com/jq-ajax-progress"></script>
JavaScript
const url = 'http://www.gutenberg.org/files/56969/56969-0.txt'
$.ajax(url, {
progress: function(e) {
// lengthComputable is available if you set Content-Length in your header
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Length
if (e.lengthComputable) {
const completedPercentage = Math.round((e.loaded * 100) / e.total);
// You can inject completedPercentage into the DOM now
console.log(completedPercentage);
}
}
})