dimanche 27 octobre 2019

Why does my Ajax Function is not working? [duplicate]

This question already has an answer here:

I have google a lot and found a solution like this:

https://www.youtube.com/watch?v=ejN-oAw9vC0&t=927s

But! My Code does still not work and i don't know why...

I have one div, one button and one jQuery Function and i already include my jQuery Javascript File.

<script src="https://www.prodigy-official.de/resources/js/jquery-3.3.1.min.js"></script>

<button class="button button3" id="button2"></button>

<div id="la">
</div>

<script>

$(document).ready(function(){
    $("button2").click(function(){
        $("la").load("test.php", {

        });
    });
});

 </script>

test.php:

<?php 


  include '/var/www/vhosts/prodigy-official.de/httpdocs/dbusers.php';
  include '/var/www/vhosts/prodigy-official.de/httpdocs/resources/php/user_utilities.php';

  $sql = "SELECT browser,os,ip_address,country,login_time FROM `user.login_history` WHERE username_id='".getUserIdInDatabase()."' ORDER BY id DESC"; 
  $result = mysqli_query($db,$sql);

  if (mysqli_num_rows($result) > 0){
    echo '<table>';
          echo '<tr>';
            echo '<th>Browser</th>';
            echo '<th>Operating System</th>';
            echo '<th>IP Address</th>';
            echo '<th>Country</th>';
            echo '<th>Login Time</th>';
          echo '</tr>';

          while($row = mysqli_fetch_array($result))
          {
            echo '<tr>';
            echo "<td>" . $row['browser'] . "</td>";
            echo "<td>" . $row['os'] . "</td>";
            echo "<td>" . $row['ip_address'] . "</td>";
            echo "<td>" . $row['country'] . "</td>";
            echo "<td>" . $row['login_time'] . "</td>";
            echo '</tr>';
          }

   echo '</table>';
 } else {
   echo '(No Data found)';
 }
 mysqli_close($db);

  ?>

Why Does it not work?




Aucun commentaire:

Enregistrer un commentaire