Я использую Laravel 5.6 и плагин datatables 1.10.18. Я получил данные от микротик. Я хочу обновлять свои данные каждые 5 секунд. Но получил ошибку.
Мой контроллер pppoeClientConnected
public function pppoeClientConnected()
{
$server = Server::find(1);
$con = Roar::connect($server->server_ip, $server->server_port,$server->username,$server->password);
if($con->isConnected()){
$active_users = new Active($con);
$users = $active_users->getAll();
} else {
Session::flash('message', 'Not Connected!');
Session::flash('m-class', 'alert-danger');
return redirect()->route('client.index');
}
return view("admin.pages.client_pppoe_connected", [
'clientData' => $users,
'page_title' => 'PPPoE Connected Client',
]);
}
Моя страница админки admin.pages.client_pppoe_connected
<thead>
<tr>
<th style="display: none" class="hidden-print"></th>
<th>#</th>
<th>Client Name</th>
<th>Username</th>
<th>Mac Address</th>
<th>Connected IP</th>
<th>Connected Time</th>
</tr>
</thead>
<tbody>
@php($i = 0)
@foreach ($clientData as $dataClient)
@php($i = $i+1)
@php($client = \App\Client::where('username', $dataClient['name'])->first())
@if($dataClient['name'] == $client['username'])
<tr>
<td style="display: none" class="hidden-print">{{ $dataClient['.id'] }}</td>
<td>{{ $i }}</td>
<td>{{ $client['client_name'] }}</td>
<td>{{ $dataClient['name'] }}</td>
<td>{{ $dataClient['caller-id'] }}</td>
<td>{{ $dataClient['address'] }}</td>
<td>{{ $dataClient['uptime'] }}</td>
</tr>
@endif
@endforeach
</tbody>
Сценарий
$(document).ready(function () {
var table = $('#datatables').DataTable({
pagingType: "full_numbers",
columnDefs: [{orderable: false, targets: [4]}]
});
setInterval(table.ajax.reload, 5000);
});
Я получил эту ошибку.
Предупреждение DataTables: table id = datatables - Неверный ответ JSON. Для получения дополнительной информации об этой ошибке см. http://datatables.net/tn/1
Как я могу перезагрузить данные таблицы?