Ver Mensaje Individual
  #4 (permalink)  
Antiguo 06/02/2008, 05:27
consigna
 
Fecha de Ingreso: enero-2008
Mensajes: 57
Antigüedad: 16 años, 3 meses
Puntos: 0
Re: Refrescar porcentaje de barra de progreso

Hola panino, muchas gracias por responderme. He probado lo que me has puesto y no me funciona, he estado mirando para utilizar la libreria javascript prototype y he probado lo siguiente, pero tampoco me funciona, que estara fallando?

Progreso.html

Código PHP:

<!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=iso-8859-1" />
<
title>Procesando</title>
<
style>
#marco{
width:300px;
border:1px solid #000;
}
#barra{
width:0background-color:#F00;
}
</
style>
<
script src="prototype.js" type="text/javascript"</script>
<script>

var porciento;

function rpc(url, porciento){
    url=url+'&'+Math.random();
    porciento= new Ajax.Request(url,
  {
    onSuccess: function(transport){
      var response = transport.responseText || "no response text";
      alert("Success! \n\n" + response);
    },
    onFailure: function(){ alert('Something went wrong...') }
  });
}

function progress(porcentaje){
document.getElementById('barra').style.width=porcentaje+'%';
}

window.onload=function(){

var pp=setInterval(function(){progress(porciento);if(porciento>99){clearInterval(pp);};rpc('procesando.php?', porciento);},50);
}

</script>
</head>

<body>
<div id="marco"><div id="barra">&nbsp;</div></div>
</body>
</html> 
y aqui lo que hago en la pagina procesando.php, que lo unico que saco es imprimir por pantalla el porcentaje que lleva ejecutado

Código PHP:



<?php

//leemos el fichero de status.log, para ver el porcentaje que lleva procesado
if(file_exists("tmp/status.log")){

   
$fp fopen "tmp/status.log" "r" ); //abrimos el fichero status
   
   
fseek($fp,10,0);
   
$porcentaje=fgets($fp);
   
fclose($fp);
   echo 
$porcentaje;
}
 
?>
Espero que alguien me pueda hechar una mano.

Saludos