I'm using this script for populating datatable
//datatable population
var table=$('#table).dataTable({
"aoColumns": [
{"data": "info"},
{"data": "emri"},
{"data": "atesia"},
{"data": "mbiemri"}
,
{
"orderable": false,
"data": null, "defaultContent":'<button class="btn green btn-outline
sbold uppercase"
data-toggle="modal"> Shiko </button>'
}
],
"initComplete": function( settings, json ) {
$("#gif").addClass("hidden");
},
procssing: true,`enter code here`
serverSide: true,
autoWidth: false,
destroy: true,
"sAjaxSource": urlinfo,
"fnServerData": function (sSource, aoData, fnCallback, oSettings) {
var data = {
name: emri,
surname: mbiemri,
fathername: atesia,
info: info,
draw: oSettings.iDraw,
start: oSettings._iDisplayStart,
length: oSettings._iDisplayLength,
};
oSettings.jqXHR = $.ajax({
"headers": {
'X-CSRF-TOKEN': ' '
},
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": data,
processData: false, contentType: false,
"success": fnCallback,
"error": function (e) {
console.log(e.message);
}
});
},
});
method that return response in laravel controller
public function searchinfo(Request $request) {
$inputs = [
'emri' => str_replace('ç','Ç',str_replace('ë','Ë',strtoupper($request->input('name')))),
'mbiemri' => str_replace('ç','Ç',str_replace('ë','Ë',strtoupper($request->input('surname')))),
'atesia' => str_replace('ç','Ç',str_replace('ë','Ë',strtoupper($request->input('fathername')))),
'info' => strtoupper($request->input('info')),
];
$params=[];
foreach($inputs as $key=>$in){
if(!is_null($inputs[$key])&& $inputs[$key]!==''){
$params[]=[$key,'LIKE', $in . '%'];
}
}
$infot = null;
if(count($params)){
$infot = Info::distinct()->select('info','emri','atesia','mbiemri','id')->where($params)->get();
}
$response = array();
$response['draw'] = ( $request->input('draw')) ? intval($request->input('draw')) : 0;
$response['recordsTotal'] = intval(count($infot));
$response['recordsFiltered'] = intval(count($infot));
$response["data"] = array();
if ($infot != null) {
$infot = $infot->slice(intval($request->input('start')), intval($request->input('length')));
foreach ($infot as $p) {
$array = [];
$array["info"] = $p->info;
$array["emri"] = $p->emri;
$array["atesia"] = $p->atesia;
$array["mbiemri"] = $p->mbiemri;
$array["id"] = $p->id;
$response["data"][] = $array;
}
}
return json_encode($response);
}
When I click next page ,I have this error in console
'Uncaught TypeError: Illegal invocation ' enter image description here
Can you help me?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire