Php 未捕获类型错误:无法设置属性';数据';空数据表的定义
我想在使用ajax删除数据表后重新加载数据表中的数据。我检查了数据库,该项已被删除,但datatables不会刷新,它会返回此错误 未捕获的TypeError:无法设置null datatables的属性“data” 拉维尔 另外,我从警报中收到了这条消息 DataTables警告:表id=table1-JSON响应无效。更多 有关此错误的信息,请参阅 代码如下: jquery:Php 未捕获类型错误:无法设置属性';数据';空数据表的定义,php,jquery,ajax,laravel,datatables,Php,Jquery,Ajax,Laravel,Datatables,我想在使用ajax删除数据表后重新加载数据表中的数据。我检查了数据库,该项已被删除,但datatables不会刷新,它会返回此错误 未捕获的TypeError:无法设置null datatables的属性“data” 拉维尔 另外,我从警报中收到了这条消息 DataTables警告:表id=table1-JSON响应无效。更多 有关此错误的信息,请参阅 代码如下: jquery: var tab= jQuery('#table1').DataTable({ "columns": [
var tab= jQuery('#table1').DataTable({
"columns": [
null,
null,
null,
{ "width": "15%" }
]
});
function getPageData() {
jQuery.ajax({
url: 'attend/f',
type: 'GET',
success: function(data){
tab.ajax.reload();
}
});
}
jQuery(".btndelete").click(function(e){
jQuery.ajaxSetup({
headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}'
}
});
var id= jQuery(this).data('id');
e.preventDefault();
swal({
title: 'Are you sure?',
text: "You won't be able to revert this!",
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, delete it!'
}).then(function () {
jQuery.ajax({
dataType: 'json',
type: 'delete',
url: 'attend/' + id + '/delete',
}).done(function(data){
getPageData();
});
})
});
路线:
public function attend1($id)
{
$acara = \App\Model\MyEventList::where('id_user',$id)->get();
return response()->json();
}
它应该是
returnresponse()->json($acara)代码>应该是returnresponse()->json($acara)代码>