Ver Mensaje Individual
  #7  
Antiguo 11-01-2008
keyboy keyboy is offline
Miembro
 
Registrado: oct 2004
Posts: 367
Reputación: 20
keyboy Va por buen camino
Estuve viendo el ejemplo que presentan, pero en mi caso la imagen no aparece sino hasta que termina de generarse el reporte. Leyendo la entrada del manual que enlazan, veo el siguiente comentario de un usuario:

Cita:
If flush() don't work remember to check if you have any antivirus caching the data sent to the browser.
Y, en efecto, al desactivar el antivirus (avast), el ejemplo funciona perfectamente.

Pensando una solución alterna, probé con ajax y al parecer funciona este ejemplo basado en el de ustedes.

Código PHP:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<
html>
<
head>
<
meta http-equiv='Content-Type' content='text/html; charset=ISO-8859-1'>
<
title>Reportes en PDF</title>
<
script type='text/javascript'>
/**
 * Crea un objeto HTTPRequest (peticiones HTTP en segundo plano)
 *
 * Posiblemente haya que ampliarla paa abarcar más casos.
 */
function createRequest()
{
    if (
window.XMLHttpRequest)
    {
        return new 
XMLHttpRequest();
    }
    else if (
window.ActiveXObject)
    {
        return new 
ActiveXObject('Microsoft.XMLHTTP');
    }

    return 
null;
}

/**
 * Manejador del evento onload
 *
 * Una vez cargada la página, hacemos una petición HTTP en segundo plano para
 * iniciar la generación del reporte. Cuando esté terminado, el evento
 * onreadystatechange se activará y ahí pondremos visible el mensaje.
 */
window.onload = function()
{
    var 
request createRequest();
    
    
request.onreadystatechange = function()
    {
        if (
request.readyState == && request.status == 200)
        {
            
oMensaje document.getElementById('mensaje');
            
oMensaje.style.display 'block';
        }
    }
    
    
request.open('get''reporte.php'true);
    
request.send();
}
</script>
</head>
<body>

<div style="text-align: center;">
    <img src="icon_inprogress.gif" width="180" 
     height="180" alt="Generando el reporte PDF..." /> 
</div>

<div style='text-align: center; display: none' id='mensaje'>
<h1>Reporte generado</h1>
</div>

</body>
</html> 
Bye
Responder Con Cita