I am trying to refresh a table of members using AJAX, and I am receiving a Notice saying that the variable that I am passing via AJAX is not Undefined. I have two files, an index.php and load-members.php, the goal is to show the first 5 members in the index page then in each time I click a button a have more members shown so find bellow the script and the file. This is my Script
<script>
$(document).ready(function() {
var membersCount = 5;
$("#btn").click(function() {
membersCount = membersCount + 5;
$("#members").load("load-members.php", {
membersNew: membersCount
});
});
});
</script>
The load-members.php file is :
<?php
include 'includes/db.inc.php';
$membersNew = $_POST['membersNew'];
echo $membersNew;
// e$membersNewcho mysqli_num_rows($query);
$sql = "select * from users LIMIT $membersNew";
$query = mysqli_query($conn,$sql);
while ( $row_admin = mysqli_fetch_assoc($query)) {
echo"<tr>
<th scope='row'>".$row_admin['user_id']."</th>
<td>".$row_admin['user_username']."</td>
<td>".$row_admin['user_email']."</td>
<td>".$row_admin['score']."</td>
<td>".$row_admin['acc']."%</td>
</tr>";
}
?>