Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

125
Vistas
Can't call a jQuery Class in PHP

I was trying to reload a div in a PHP function but it does not work. Everything work but not the div reload:

function refresh() {
    $servername = "localhost";
    $username = "root";
    $password = "";
    $db = "wp_4lous";
    $conn = new mysqli($servername, $username, $password, $db);
    $checklog = mysqli_fetch_row(mysqli_query($conn, 'SELECT numero_voti FROM voti WHERE candidato="LOG"'));
    if ($checklog[0] == '10') {
        mysqli_query($conn, 'UPDATE voti SET numero_voti="0" WHERE candidato="LOG" AND numero_voti="10"');
        echo '<script> updateDiv(); </script>';
    }
};
?>

<script type="text/javascript">
function updateDiv()
{ 
    $("#here").load(window.location.href + " #here" );
}
</script>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can try a different approach, the way you are doing will not work. Use a php variable and assign something usefull to understand that your SQL update is done, and use that variable inside the script to do the work.

Sample code below - I have used a variable $recUpdated, and modified your code, take a look.

    $recUpdated = "NO";

    function refresh() {
            $servername = "localhost";
            $username = "root";
            $password = "";
            $db = "wp_4lous";
            $conn = new mysqli($servername, $username, $password, $db);
            $checklog = mysqli_fetch_row(mysqli_query($conn, 'SELECT numero_voti FROM voti WHERE candidato="LOG"'));
            if ($checklog[0] == '10') {
                    mysqli_query($conn, 'UPDATE voti SET numero_voti="0" WHERE candidato="LOG" AND numero_voti="10"');
                    $recUpdated = "YES";
            }
    };
    ?>

    <script type="text/javascript">

        <?php if($recUpdated == "YES") { ?>
            $("#here").load(window.location.href + " #here" );
        <?php } ?>

    </script>
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda