我正在使用Laravel 5.6和datatables插件1.10.18。我从mikrotik获得了数据。我想每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警告:表id = datatables-无效的JSON响应。有关此错误的更多信息,请参见http://datatables.net/tn/1
如何重新加载表格数据?