jquery – datatables refresh table after ajax loaded data from mysql | PHP-ThrowExceptions

Exception or error:

I have the following datatable code as part of displaying table of information from mysql database:

      <table class="striped highlight" id="clientsTable">
          <input type="hidden" id="result_no" value="2">
          <tbody id="result_para">
foreach ($results as $result) {
  $clientsName = $result['clientNameA'];
    $clientsName .= ' ו-' .$result['clientNameB'];
   }else {
    $clientsName .= '';
         <td><?php echo $clientsName; ?></td>
         <td><?php echo $result['eventLocation']; ?></td>
         <td><?php echo $result['eventDate']; ?></td>
         <td><?php echo $result['clientPackage']; ?></td>
         <td class="">
         <span class="<?php $this->checkStatment($result['clientStatus'],'active,'chip-active');$this->checkStatment($result['clientStatus'],'tempo,'chip-tempo');
         $this->checkStatment($result['clientStatus'],'archive,'chip-archive');?>"><?php echo $result['clientStatus']; ?></span>
           <a data-target="updateClient" href="#!" class="modal-trigger waves-effect waves-light"
           data-idclients="<?php echo $result['idClients']; ?>"
           data-clientnamea="<?php echo $result['clientNameA']; ?>"
           data-clientnameb="<?php echo $result['clientNameB']; ?>"
           data-clientemail="<?php echo $result['clientEmail']; ?>"
           data-eventlocation="<?php echo $result['eventLocation']; ?>"
           data-clientphone="<?php echo $result['clientPhone']; ?>"
           data-eventdate="<?php echo $result['eventDate']; ?>"
           data-eventguests="<?php echo $result['eventGuests']; ?>"
           data-clientstatus="<?php echo $result['clientStatus']; ?>"
           ><i class="material-icons">edit</i></a>

And the following code to add more tr fields into it with ajax:

        $("#loadMore").click(function () {

function loadmore(trigger)
     var val = document.getElementById("result_no").value;
        type: 'post',
        url: 'resources/php/loadMoreClients',
        data: {
            getresult: val,
        success: function (response) {
            var content = document.getElementById("result_para");
            content.innerHTML = content.innerHTML + response;
            document.getElementById("result_no").value = Number(val) + 2;

Unfortunately every time I push new data into the table datatables do not refresh and the search function as well as the sorting is not working. You can see I tried to clear it with:


and then draw it again with:


It is not working. Any ideas?

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *