AJAX Call - 收到通知:未定义的索引

时间:2018-05-01 19:00:53

标签: javascript php ajax

我正在尝试使用AJAX刷新成员表,我收到一条通知说我通过AJAX传递的变量不是Undefined。我有两个文件,一个是index.php和load-members.php,目标是在索引页面中显示前5个成员然后在每次单击一个按钮时显示更多成员,所以找到下面的脚本和文件。 这是我的剧本

    <script>
$(document).ready(function() {
  var membersCount = 5;
    $("#btn").click(function() {
      membersCount = membersCount + 5;
      $("#members").load("load-members.php", {
          membersNew: membersCount
      });
    });  
});
</script>

load-members.php文件是:

    <?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>";

}
?>

0 个答案:

没有答案