Ver Mensaje Individual
  #1 (permalink)  
Antiguo 25/10/2013, 18:57
Avatar de zeuzft
zeuzft
 
Fecha de Ingreso: junio-2009
Ubicación: peru
Mensajes: 358
Antigüedad: 14 años, 10 meses
Puntos: 2
Exclamación no ejecuta funcion javascript desde php

Estoy intentando simular el llenado de un tanque de agua, para lo cual utilizo 3 archivos, listar.php; el que contiene la programacion inicial de javascript y llama al archivo leo.php que hace la lectura de la bd para ver el estado del tanque y este a su vez llama a tanque.php, que deberia de ejecutar la funcion javascript para simular el llenado; el problema es que si la funcion runTest() la ubico en el onload del index, funciona normal pero la trato de invocar desde el php, no ejecuta:
listar.php
Código PHP:
<div id='pases'>
<
style type="text/css">
<!--
#tester {
    
background-color#900;
    
height300px;
    
width300px;
}
#holder {
    
background-color#E5E5E5;
    
height300px;
    
width300px;
    
floatleft;
    
margin-right30px;
    
margin-bottom30px;
}
#fadeToggle {
    
clearboth;
}
-->
</
style>

<
script type="text/javascript">
$(
document).ready(function() {    

    
jQuery.fn.fadeToggle = function(speedeasingcallback) {
        return 
this.animate({opacity'toggle'}, speedeasingcallback);  
    };
                           
    function 
resetTest() {
        
effectType = $('#effectType').val();
        if (
effectType == 'slideToggle()') {
            $(
'#tester').slideUp(0)
        }
    }
        
    $(
'#effectType, #easeType').change(function() {
        $(
this).blur()
        
resetTest()
    })
    
    $(
'#reset').click(function() {
        
resetTest()
    })

    
resetTest()
    
    $(
'#fadeToggle').click(function() {
        $(
this).next('.explaination').slideToggle(800'easeOutCubic');
    })
    
})

    function 
runTest() {
        
easeType 'linear';
        
effectType 'slideToggle()';
        
testDuration 3000;
        
        $(
'#testDuration, #test, #reset').blur()
        
        if (
effectType == 'slideToggle()') {
            $(
'#tester').slideToggle(testDuration,easeType)
        }
    }
</script>
</div>
<div align='right'>
    <script type='text/javascript'>
        function cambios()
        {
            $.ajax({
                url: "leo.php",
                cache: false,
                success: function(html){
                    $("#cambiante").html(html); //Inserta el log de chat en el div #cambiante
                },
            });
        }
    </script>
<div id='cambiante'>

</div>
</div>
<br/>
<div id="holder" align='right' style="float:relative">
    <div id="tester"></div>
  </div>
<div id='divResultado' align='right' style="float:relative">
</div> 
leo.php
Código PHP:
<?php
require("../../clases/3_logicaNegocio/DistribucionLogic.php");  
$Controlador = new DistribucionLogic ;
$listado=$Controlador->Suceso();
$a0=$listado['er'];
$actual='';
if(
$actual==''){ $a=$a0$actual=$a0; }
?>
<br/>
<table width='800' align='center' cellspacing='2' cellpadding='2' border='0' class="tablagradient">
    
    <tr>
        <th>
            <?php
            
switch ($a)
            {
                case 
:
                    echo 
"tanque vacio";
                    
?>
                    <script type='text/javascript'>
                        enviaQuery('divResultado','../../funcion/tanque.php?opcion=veo&estado=0');
                    </script>
                    <?php
                    
break;
                case 
:
                    echo 
"llenando tanque"
                    
?>
                    <script type='text/javascript'>
                        enviaQuery('divResultado','../../funcion/tanque.php?opcion=veo&estado=1');
                    </script>
                    <?php
                    
break;
                case 
:
                    echo 
"tanque lleno"
                    
?>
                    <script type='text/javascript'>
                        enviaQuery('divResultado','../../funcion/tanque.php?opcion=veo&estado=2');
                    </script>
                    <?php
                    
break;
                case 
:
                    echo 
"distribuyendo agua"
                    
?>
                    <script type='text/javascript'>
                        enviaQuery('divResultado','../../funcion/tanque.php?opcion=veo&estado=3');
                    </script>
                    <?php
                    
break;
            }
            
?> 
        </th>
    </tr>
</table>
tanque.php
Código PHP:
<?php
session_start
();
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0"false);
header("Pragma: no-cache");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " gmdate("D, d M Y H:i:s") . " GMT"); 

if (
$_GET['opcion']=="veo")
{
    
$estado=$_GET['estado'];
    
    switch (
$estado)
            {
                case 
:
                    echo 
"<img src='../../../web/images/vacio.png' height='200px' />";
                    break;
                case 
:
                    
?>
                    <script type='JavaScript'>
                        runTest();
                    </script>
                    <?php
                    
echo "<img src='../../../web/images/llenando.png' height='200px' />";
                    break;
                case 
:
                    echo 
"<img src='../../../web/images/descargando.png' height='200px' />";
                    break;
                case 
:
                    echo 
"<img src='../../../web/images/vacio.png' height='200px' />";
                    break;
            }
}

?>
y aqui ubico mi index.php con el onload.
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=utf-8" />
        <!-- 
styles -->
        <
link type="text/css" rel="stylesheet" href="../../../web/css/style-azul.css" />
        
        <!-- 
scripts -->
        <
script type="text/JavaScript" src="../../../web/js/jquery1.10.2.js"</script>
        <script type="text/javascript" src="../../../web/js/tiny_mce/tiny_mce.js"></script>
        <script type="text/JavaScript" src="../../../web/js/livevalidation.js"> </script>
        <script type="text/JavaScript" src="../../../web/js/jquery.easing.1.3.js"></script>
        <script type="text/JavaScript" src="../../../web/js/myajax.js"> </script>
        <script type="text/JavaScript" src="../../../web/js/titulo.js"> </script>
        <script type="text/javascript" src="../../../web/js/lightview/lightview.js"></script>
        <link rel="stylesheet" type="text/css" href="../../../web/css/lightview/lightview.css"/>
        
    </head>
    <body onLoad="setInterval('cambios()',1000);setInterval('runTest()',1000);">