M
MaxivB
Hallo,
ich habe eine Progressbar für meinen Upload gebastelt, ich verwende dafür GDownloadUrl:
Jetzt hab ich das mit XmlHttp getestet, aber das funktioniert nicht:
Was muss ich ändern, damit es funktioniert?
Danke im Voraus.
ich habe eine Progressbar für meinen Upload gebastelt, ich verwende dafür GDownloadUrl:
Code:
function getProgress(){
GDownloadUrl("getprogress.php?progress_key=<?php echo($id)?>",
function (percent, responseCode) {
percent = percent.split("|");
current = percent[0] / 1000000;
size = percent[1] / 1000000;
percent = percent[0] / percent[1] * 100;
document.getElementById("progressinner").style.width = percent + "%";
document.getElementById("percentbar").innerHTML = Math.round(percent) + "% (" + Math.round(current) + " MB von " + Math.round(size) + " MB)";
if (percent < 100) {
setTimeout("getProgress()", 100);
}
else {
document.getElementById("finished").style.display = "block";
document.getElementById("bar").style.display = "none";
document.getElementById("form").style.display = "block";
document.getElementById("progressinner").style.width = "0%";
document.getElementById("percentbar").innerHTML = "0% (0 MB von 0 MB)";
}
});
}
Code:
var xmlHttp = false;
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e) {
xmlHttp = false;
}
}
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
xmlHttp = new XMLHttpRequest();
}
function getProgress() {
var percent = "";
if (xmlHttp) {
xmlHttp.open('GET', 'getprogress.php?progress_key=<?php echo($id)?>', true);
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState == 4) {
if (xmlHttp.responseText != "") {
percent = xmlHttp.responseText;
}
}
}
};
percent=1;
percent = percent.split("|");
current = percent[0] / 1000000;
size = percent[1] / 1000000;
percent = percent[0] / percent[1] * 100;
document.getElementById("progressinner").style.width = percent + "%";
document.getElementById("percentbar").innerHTML = String(Math.round(percent)) + "% (" + Math.round(current) + " MB von " + Math.round(size) + " MB)";
if (percent < 100) {
setTimeout("getProgress()", 100);
}
else {
//document.getElementById("finished").style.display = "block";
//document.getElementById("bar").style.display = "none";
//document.getElementById("form").style.display = "block";
//document.getElementById("progressinner").style.width = "0%";
//document.getElementById("percentbar").innerHTML = "0% (0 MB von 0 MB)";
}
}
Was muss ich ändern, damit es funktioniert?
Danke im Voraus.