Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

123
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!