I am currently working on a PHP/JS script that will help me manage the status of all the windows terminal servers. The WMI access is quite slow, so I decided to use AJAX to display the progress of each server as it loops through them. The script works perfectly fine in Firefox. However, in Chrome, it does not show the status while looping; only after the loop is completed. And in IE11, the code simply doesn't work at all. Even though IE calls both functions and enters the if statement to create the request object. Can anybody assist me in getting IE to work properly and Chrome to display the status during the loop? Thank you for any help you can provide.
Here's my current code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="tsmanager.css">
<script type="text/javascript">
function refreshall()
{
var table = document.getElementById("terminalservers");
for (var i = 0, row; row = table.rows[i]; i++)
{
var sComputer = row.id;
if (sComputer != "")
{
setTimeout(refresh(sComputer), 2000);
setTimeout(document.getElementById("turn").innerHTML = sComputer, 2000);
}
}
}
function refresh(sComputer)
{
if (window.XMLHttpRequest)
{
req = new XMLHttpRequest();
}
else
{
req = new ActiveXObject("Microsoft.XMLHTTP");
}
req.onreadystatechange = function()
{
if (req.readyState == 4 && req.status == 200)
{
document.getElementById(sComputer).innerHTML = req.responseText;
}
}
req.open("GET", "serverrequest.php?name="+sComputer, false);
req.send();
}
</script>
</head>
<body>
<table id="terminalservers">
/* some table content with row id=servername */
</table>
<button onclick="refreshall()">alle</button>
<br><span id="turn">leer</span>
</body>
</html>