title: Retrieve data from php to jquery and insert it into DataTable
body: <p>I want to refresh content of table from database , so when user pressed refresh button I will retrieve data from database via php , and send this data to jquery which will working on insert retrieved data into table ,I can retrieve data successfully but can not insert it in to datatable 
  this is php code which retrieve data from database;</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>    elseif ($id=='refresh_logs'){
  
     $shortname=$_GET['shortname'];
        $data_array = array();
      $bul="select radacct.UserName,radacct.AcctStartTime,radacct.AcctStopTime,radacct.AcctOutputOctets,radacct.AcctInputOctets,AcctSessionTime,FramedIPAddress,os.mac,nas.shortname,os_platform,acctupdatetime ,RadAcctId from radacct Left join os on os.username=radacct.UserName and os.AcctSessionid=radacct.AcctSessionId left join nas on radacct.NASIPAddress = nas.nasname where nas.shortname='$shortname' limit 1";
   //echo($bul);
   $result2 = $con2-&gt;query($bul);
    while($row = $result2-&gt;fetch_assoc()) {
      $upload=round($row['AcctOutputOctets']/1024/1024,2);
     
      $download=round($row['AcctInputOctets']/1024/1024,2);
     if ($row['AcctSessionTime']&lt;60) {
        $sure=$row['AcctSessionTime']." Sec";
      }
     else {
       $gun=floor($row['AcctSessionTime']/86400);
       $saat=floor(($row['AcctSessionTime'] - $gun*86400)/3600);
       $dakika=floor(($row['AcctSessionTime'] - $gun*86400 - $saat*3600)/60);
       $sure="";
       if ($dakika&gt;0){
         $sure=$dakika." Min";
        }
       if ($saat&gt;0){
         $sure=$saat." Hour ".$sure;
       }
       if ($gun&gt;0){
        $sure=$gun." Day ".$sure;
        }
      }
     $row['upload']=$upload;
     $row['download']=$download;
     $row['sure']=$sure;
      array_push($data_array,$row);
      
      
      
      }
  
     $data_array=json_encode($data_array); 
   echo $format = '{
  "data":['.$data_array.']}';
   
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>this is the jquery code to insert retrieved data into table</p>
  
  <pre><code>$('.refresh').click(function(e) {
      e.preventDefault();
  
  
      var string ='';
      var nas_shortname=$('#nas_shortname').val();
  
      var jsonData = $.ajax({ async: false,
        url: "Save.php?id=refresh_logs&amp;shortname="+nas_shortname,
  
        dataType: "json"
  
        }).responseText;
          //}
  
  var obj = $.parseJSON(jsonData);
  $('#resultt').html('&lt;img src="dist/img/ajax_loader_red_128.gif"/&gt;');
  $('#my_logs tbody ').remove();
  
  
  
  
  
  
  
  $.fn.dataTable.ext.errMode = 'throw';
  var table = $('#my_logs').DataTable({
  "processing": true,
  "serverSide": true,
  "ajax": obj,
  "sScrollY": "300px",
  "scrollX":true,
  "paging": false,
  "bFilter": false,
  "bInfo": false,
  "searching": false,
  "bSort" : false,
  "fixedColumns":   true
  });
  
  
  $('#resultt').html('OK');
  }); 
  
  
  
  });
  </code></pre>
  
  <p>I have this error in console</p>
  
  <blockquote>
    <p>DataTables warning: table id=my_logs - Invalid JSON response. For more information about this error, please see <a href="http://datatables.net/tn/1" rel="nofollow noreferrer">http://datatables.net/tn/1</a>
        at J (VM2914 jquery.dataTables.min.js:74)</p>
  </blockquote>
  
  <p>this is json data which I send from server side to jquery </p>
  
  <pre><code>[{"UserName":"root2","AcctStartTime":"2018-10-18 15:52:52","AcctStopTime":null,"AcctOutputOctets":"0","AcctInputOctets":"0","AcctSessionTime":"0","FramedIPAddress":"192.168.33.3","CallingStationId":"192.168.33.3","shortname":"radius2_nas1","os_platform":null,"acctupdatetime":"2018-10-18 15:52:52","RadAcctId":"1","upload":0,"download":0,"sure":"0 Sec"},{"UserName":"root","AcctStartTime":"2018-10-18 16:07:00","AcctStopTime":null,"AcctOutputOctets":"0","AcctInputOctets":"0","AcctSessionTime":"0","FramedIPAddress":"192.168.33.3","CallingStationId":"192.168.33.3","shortname":"radius2_nas1","os_platform":null,"acctupdatetime":"2018-10-18 16:07:00","RadAcctId":"2","upload":0,"download":0,"sure":"0 Sec"}]
  </code></pre>