Hey.
I'm using AJAX (no Framework) to list Documents contained in Directories on the Server.
First:
The "getfiles.php" asks MySQL if the directory is password protected. If yes it returns "!pw!".
So if the responseText matches "!pw!" the second request should be triggered with the entered password and return the Documentlist.
Chrome and FireFox 3+ & 4 are doing well... but IE6 still refuses to load the List, after the password has typed in.
P.S.: Sorry for my bad English.
function showFiles(str)
{
var xmlhttp = false;
if (str=="")
{
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest) { // Mozilla, Safari,...
xmlhttp = new XMLHttpRequest();
if (xmlhttp.overrideMimeType) {
xmlhttp.overrideMimeType('text/xml');
}
} else if (window.ActiveXObject) { // IE
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!xmlhttp) {
alert('Unfortunately you browser doesn\'t support this feature.');
return false;
}
xmlhttp.onreadystatechange=function()
{
switch (xmlhttp.readyState)
{
case 4:
if (xmlhttp.status==200)
{
if (xmlhttp.responseText.match("!pw!"))
{
var pw = prompt ("A Password is required!
If you don\'t have the Password, please ask your Colleagues","Passwort needed");
xmlhttp.open("GET","getfiles.php?f="+str+"&pw="+pw,true);
xmlhttp.send();
}
else
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
break;
default:
document.getElementById("txtHint").innerHTML="<div align=\"center\"><img src=\"../_img/wait.gif\"/></div>";
break;
}
}
xmlhttp.open("GET","getfiles.php?f="+str,true);
xmlhttp.send();
}
Instantiate a new XMLHttpRequest each time you start a new request instead of reusing the previous instance. That should fix it.