简体   繁体   中英

Refresh with ajax and php

I'm working on being able to refresh a div that contains data from a database.

I have established this code here but when I open the F12 console, this error appears:

Uncaught ReferenceError: $ is not defined at loadlink (index.php:29:17) at index.php:34:13

I have two files an index file and a commands file or on the index file I will include a commands.php

    <!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title></title>
</head>
<body>
    <div class="commandes">
     <?php
            $sql = "SELECT enc_id, enc_cmd_num, enc_paye, enc_prepared, enc_ext_ref, enc_heure_fab_deb, enc_type, enc_heure_fab_fin, Client.cli_civilite,Client.cli_nom, Client.cli_prenom FROM Client RIGHT JOIN encaissement ON Client.cli_id = encaissement.enc_client WHERE enc_etat<>4 AND enc_date= convert(date,getdate()) AND ((DATEDIFF(n,enc_heure_fab_fin, getDate()) < 3 AND enc_prepared <> 0) OR enc_prepared = 0) AND enc_emporte <> 1 ORDER BY encaissement.enc_heure_fab_deb ASC";

            $results = odbc_exec( $conn, $sql );
    ?>


<table>
            <?php
                while( $row = odbc_fetch_array( $results ) )
                {
                    printf('<tr>');

                    if ( $row["enc_ext_ref"] != '')
                        {
                            $num_cmd = $row["enc_ext_ref"];
                        }
                    else
                        {
                            $num_cmd =$row["enc_cmd_num"];
                        }


                    if ($row['enc_paye'] = 0)
                    {
                        $etat_cmd='<span class="PRETE">ATTENTE REGLEMENT</span>';
                    }
                    else
                    {
                        switch( $row['enc_prepared'] )
                        {
                            case 0: $etat_cmd='<span class="ENPREPA">EN PREPARATION</span>'; break;

                            case 1:
                                $etat_cmd='<span class="PRETE">COMMANDE PRETE</span>'; break;break;
                        }
                    }


                    switch( $row['enc_type'] )
                    {
                        case 0: $commande='<span class="EMPORTER"></span>'; break;

                        case 1: $commande='<span class="LIVRAISON"></span>'; break;

                        case 2: $commande='<span class="SURPLACE"></span>'; break;
                    }



                    printf('<td>%s%s%s</td>',$row["enc_cmd_num"],$etat_cmd, $commande);
               
                }

            ?>



            </table>
        </div>

        <script>
            function loadlink(){
                $('#commandes').load('commandes.php', function() {

                });
            }

            loadlink();
            setInterval(function(){
                loadlink()
            }, 10000);
        </script>

Put

<script src="https://code.jquery.com/jquery-3.6.3.min.js" integrity="sha256-pvPw+upLPUjgMXY0G+8O0xUf+/Im1MZjXxxgOcBQBXU=" crossorigin="anonymous"></script>

before <script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2025 STACKOOM.COM