0
我想让Ajaz每5秒使用一个php文件从数据库中获取数据,并且过程继续。它似乎在Firefox中工作很好,但不会在IE中更新。Ajax settimeout从php/mysql中读取状态
任何人都可以帮助使这个平台独立?
阿贾克斯/ jQuery代码
function startprogress() {
$.get("status.php");
setTimeout('updateStatus()', 500);
}
function updateStatus() {
$("#progress").load("status.php");
setTimeout('updateStatus()', 500);
}
PHP文件
mysql_connect("localhost","root","password") or
die("Could not connect: " . mysql_error());
mysql_select_db("table");
$sql="SELECT current, total FROM status WHERE id = 1";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
echo "Completed: " . $row['current'] ." of " . $row['total'];
}
然后,我在我的HTML文件的进度ID的空div,我有onclick事件触发startprogress()功能。
任何人都可以帮忙吗?
非常感谢。
如果你想要活的东西,你应该检查像websocket /节点。另外,我认为你应该使用setInterval()来代替。 – malletjo
切换到setInterval。很好的工作,但脚本完成后才停止,直到刷新浏览器。虽然它适用于我的目的。 – Reg