If your api call is working then it's your view that is broken.
Here is a sample of what I've done.
jquery part:
$(document).ready(function() {
oTable =
$('#table').DataTable({
"processing": true,
"serverSide": true,
"ajax": "{{ URL::to('/admin/api/tickets') }}",
"columns": [
{data: 'first_name', name: 'first_name', orderable: false, searchable: true, visible: false},
{data: 'make', name: 'make', orderable: false, searchable: true, visible: false},
{data: 'model', name: 'model', orderable: false, searchable: true, visible: false},
{
data: 'id',
name: 'id',
orderable: true,
searchable: false,
visible: false
},
{
data: 'title',
name: 'title',
orderable: true,
searchable: true
},
{
data: function(d){
return d.last_name + ', ' + d.first_name;
},
name: 'last_name',
orderable: true,
searchable: true
},
{
data: 'status',
name: 'ticket_status_translations.name',
orderable: true,
searchable: true
},
{
data: 'priority',
name: 'priority_translations.name',
orderable: true,
searchable: true
},
{
data: function(d){
return d.make + ' : ' + d.model + ' : ' + d.model_number;
},
name: 'model_number',
orderable: true,
searchable: true
},
{
data: 'updated_at',
name: 'updated_at',
orderable: true,
searchable: true
},
{
data: 'actions',
name: 'actions',
orderable: false,
searchable: false
}
]
});
});
table:
<div class="row">
<table id="table" class="table table-striped table-hover">
<thead>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
<th>{{ trans('kotoba::table.title') }}</th>
<th>{{ Lang::choice('kotoba::table.user', 1) }}</th>
<th>{{ trans('kotoba::table.status') }}</th>
<th>{{ trans('kotoba::table.priority') }}</th>
<th>{{ trans('kotoba::table.asset') }}</th>
<th>{{ trans('kotoba::table.updated_at') }}</th>
<th>{{ Lang::choice('kotoba::table.action', 2) }}</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
I also have a join table going on.
In your code:
$(function() {
$('#data-table-large-2').DataTable({
processing: true,
serverSide: true,
ajax: '{!! route('datatables.data') !!}',
columns: [
{ data: 'SIM no', name: 'SIM no' },
{ data: 'Voice Number', name: 'Voice Number' }
]
});
});
could possibly be ....
$(function() {
$('#data-table-large-2').DataTable({
processing: true,
serverSide: true,
ajax: '{!! route('datatables.data') !!}',
columns: [
{ data: 'sim_no', name: 'sim_no' },
{ data: 'voice_number', name: 'voice_number' }
]
});
});
I have never bothered trying to figure out why data isn't the information from the query.
If you get a datable 07 error. Make sure your table columns match up with your jquery call. This is why I have empty < th > headers in there.