How to show progress bar for video files downloading through XML request
var xhr = new XMLHttpRequest(); xhr.open(“GET”, url, true); xhr.responseType = “blob”; xhr.onload = function () { if (xhr.status === 200) { var urlCreator = window.URL || window.webkitURL; var videoUrl = urlCreator.createObjectURL(this.response); var fileName = `${candidateName}_${viewType}_${testName}.mp4`; var tag = document.createElement(“a”); tag.href = videoUrl; tag.download = fileName; document.body.appendChild(tag); tag.click(); document.body.removeChild(tag); urlCreator.revokeObjectURL(videoUrl); } else { alert(“Failed to download […]
Get URL inside function that decorate method onreadystatechange of XMLHttpRequest
I need to add a special header to all requests sent using XMLHttpRequest in my project. I achieved this by decorating onreadystatechange
the method of XMLHttpRequest: