Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

133
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda