o我在使用 jQuery 从 MySQL 数据库中获取评论时遇到问题。
我正在尝试这种方式,但它不起作用。
PHP (comments.php)
<?php 
    if (isset($_POST['value1'])) {
        $id = ($_POST['value1']);
    }else{
        $id = '';
    } 
    if (isset($_POST['value2'])) {
        $database = ($_POST['value2']);
    }else{
        $database = '';
    } 
    if (isset($_POST['value3'])) {
        $tablename = ($_POST['value3']);
    }else{
        $tablename='';
    } 
    require_once('rt-connect.php');
    $find_data = "SELECT * FROM $tablename";
    $query = mysqli_query($connection, $find_data);
?> 
  <?php while($row = mysqli_fetch_assoc($query)):?>
  <div class="comment-container">
    <div class="user-info"><?php echo $row['user_name']; ?></div>
    <div class="comment"><p><?php echo $row['comment']; ?></p></div>
  </div>
  <?php endwhile;?>
jQuery(comments.html)
     var id=2;
 var database='comments_db';
 var tablename='comments';
 $.post('comments.php', {value1:id, value2:database, value3:tablename}, function(data)
    {
    $('#comments').load('comments.php .comment-container');
 });
Html(在comments.html上加载评论的div)
      <div id="comments"></div><!--end of comments-->
请查看并建议任何可能的方法。
谢谢