This request works correctly, but the element #progress-bar does not change its width at all, although I made sure that the code works in the visual studio code
$.ajax({
url: link,
type: "GET",
dataType: "html",
xhr: function() {
var xhr = new window.XMLHttpRequest();
xhr.addEventListener("progress", function(event) {
if (event.lengthComputable) {
// Problem Is Here
$("#progress-bar").css({"width":`${(event.loaded / event.total) * 100}%`});
}
}, false);
return xhr;
},
success: function(data) {
setTimeout(function(){
document.title = `${ $(data).filter("title").text() }`;
var parsedData = $.parseHTML(data);
var bodyContent = $(data).filter(".body").html();
$("body").html(bodyContent);
},200);
history.pushState(null,null,link);
},
error: function() {
console.log("Error")
}
});