Is there a way for the xjr object to access the total data size in KB or MB? I have been using the progress event and it can track this, so I was curious about obtaining the total data size.
Here is the code snippet:
var container = Pub.el('#super-1');
if (container) {
xhr.addEventListener("progress", function(evt){
if (evt.lengthComputable) {
var percent = ( evt.loaded / evt.total ) * 100;
var exists = document.getElementById(config_ajax.url)
if(exists){
Pub.log('div exists');
exists.style.width = percent + '%';
} else {
Pub.log('div created');
var div = document.createElement('div');
div.id=config_ajax.url;
div.style.width = percent + '%';
div.style.height = '5px';
div.style.background = 'rgba(255,255,255,0.2)';
div.style.borderBottom = '1px solid white';
container.appendChild(div);
}
}
}, false);
}
return xhr;
};