title: jquery ajax post data in php only works for the first time
body: <p>I'm trying to delete data using jquery ajax in PHP. I'm able to delete the data for the first time but it doesn't work the second time. It only works when i refresh the page after the first time. I checked the HTML response by ajax to make sure nothing wrong but it still not works. Here is my code.</p>
  
  <p>index.php</p>
  
  <pre><code> &lt;div class="container"&gt;
          &lt;br&gt;
          &lt;button class="btn btn-primary" data-toggle="modal" data-target="#insert"&gt;Thêm sinh viên&lt;/button&gt;
          &lt;h1 align="center"&gt;Bảng sinh viên&lt;/h1&gt;
          &lt;table class="table"&gt;
              &lt;thead&gt;
                  &lt;tr&gt;
                  &lt;th scope="col"&gt;Mã SV&lt;/th&gt;
                  &lt;th scope="col"&gt;Tên&lt;/th&gt;
                  &lt;th scope="col"&gt;SĐT&lt;/th&gt;
                  &lt;th scope="col"&gt;Giới tính&lt;/th&gt;
                  &lt;th scope="col"&gt;Hành động&lt;/th&gt;
                  &lt;/tr&gt;
              &lt;/thead&gt;
              &lt;tbody id="list"&gt;
                  &lt;?php include('show.php') ?&gt;
              &lt;/tbody&gt;
          &lt;/table&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>AJAX</p>
  
  <pre><code>  $(".delete").on('click',function(){
              var id = $(this).data('id');
              var result = confirm("Bạn có muốn xoá sinh viên này không ?");
              if(result){
                  $.ajax({
                      type: "POST",
                      url:"delete.php",
                      data: {'id':id},
                      success: function(response){
                          alert("Xoá thành công");
                          document.getElementById("list").innerHTML= response;
                      }
                  })
              }
          })
  </code></pre>
  
  <p>delete.php</p>
  
  <pre><code>require_once('db.php');
      $real_id = $_POST['id'];
      $sql = "DELETE FROM students WHERE real_id = ?";
      //DELETE FROM table_name WHERE condition;
      $stmt  = $mysqli-&gt;prepare($sql);
      $stmt-&gt;bind_param("s",$real_id);
      $stmt-&gt;execute();
      include("show.php");
  </code></pre>
  
  <p>show.php</p>
  
  <pre><code>$data ="";
      while($row = $result-&gt;fetch_assoc()){
  
          $data .="&lt;tr&gt;";
          $data .= "&lt;td&gt;".$row['id']."&lt;/td&gt;";
          $data .= "&lt;td&gt;".$row['name']."&lt;/td&gt;";
          $data .= "&lt;td&gt;".$row['phone']."&lt;/td&gt;";
          switch ($row['sex']) {
              case "1":
                  $sex = "Nam";
                  break;
              case "2":
                  $sex = "Nữ";
                  break;
              case "3":
                  $sex = "Khác";
                  break;
          }
          $data .= "&lt;td&gt;".$sex."&lt;/td&gt;"; 
          $realid = $row['real_id'];
          $data .= "&lt;td&gt;&lt;button class='btn btn-danger delete' data-id='$realid'&gt;Xoá&lt;/button&gt;&lt;/td&gt;";
          $data .="&lt;/tr&gt;";  
      }
      echo($data);
  </code></pre>