Reputation: 23
I have found similar questions but none as specific as this one. The following code is a simplified version that reproduces the problem.
<?php
function addProgressText($texto)
{
echo '<script type="text/javascript">';
echo 'document.getElementById("mensajesEnProgreso").innerHTML += "'.$texto.'";';
echo '</script>';
flush();
ob_flush();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width" />
<title>TEST - Flush for Android</title>
</head>
<body>
<div id="divEnProgreso">
<p id="mensajesEnProgreso"></p>
</div>
<?php
addProgressText("Init...");
sleep(5);
addProgressText("OK<br>Step 1... ");
sleep(5);
addProgressText("OK<br>Step 2... ");
sleep(5);
addProgressText("OK<br>Step 3... ");
sleep(5);
addProgressText("OK<br>FINISHED");
?>
</body>
</html>
The code works as expected (displays the steps one by one) on Chrome, Firefox and IE, but when I open it from an Android browser, the flushes don't work and everything is displayed at once upon completion.
Any hints on the source of the problem? Thanks
Upvotes: 2
Views: 465