I use server-side jquery datatable to preview some data. On backend I use Laravel 5.1 framework.
When I return the json encoded data from server side, the error occurred => Warning: Request Unknown for parameter ...
I have checked my data on server side and everything is clean.
Here is the code for this problem:
$result = \DB::table('table1')->select(\DB::raw($columns)) ->whereRaw('somecondition') ->groupBy(\DB::raw($q))->get();
return [ "aaData" => $result ];
after my function return this set of result I use:
return Response::json($response);
$response represents ["aaData" => $result]; (set of data)
and the code on client side is:
$table.dataTable({
bProcessing: true,
sAjaxSource: "{{url('/dashboard/getTableData')}}",
"fnServerParams" : function(aoData)
{
aoData.push({name: 's_date', value: $('[name=start]').val()});
aoData.push({name: 'e_date', value: $('[name=end]').val()});
aoData.push({name: 'esp', value: $('[name=sel_esp]').val()});
aoData.push({name: 'client', value: $('[name=sel_client]').val()});
aoData.push({name: 'camp', value: $('[name=sel_camp]').val()});
aoData.push({name: 'spf', value: $('[name=sel_spf]').val()});
aoData.push({name: 'dkim', value: $('[name=sel_dkim]').val()});
aoData.push({name: 'dmarc', value: $('[name=sel_dmarc]').val()});
aoData.push({name: 'host', value: $('[name=sel_host]').val()});
aoData.push({name: 'ip', value: $('[name=sel_ip]').val()});
aoData.push({name: 'spam', value: $('[name=sel_folder]').val()});
aoData.push({name: 'ar', value: $('[name=sel_ar]').val()});
},
/*
"aoColumnDefs": [
{ "sName": "date", "aTargets": [ 0 ] },
{ "sName": "esp", "aTargets": [ 1 ] },
{ "sName": "client", "aTargets": [ 2 ] },
{ "sName": "camp_id", "aTargets": [ 3 ] },
{ "sName": "host", "aTargets": [ 4 ] },
{ "sName": "ip", "aTargets": [ 5 ] },
{ "sName": "spf_f", "aTargets": [ 6 ] },
{ "sName": "dkim_f", "aTargets": [ 7 ] },
{ "sName": "dmarc_f", "aTargets": [ 8 ] },
{ "sName": "spam", "aTargets": [ 9 ] },
{ "sName": "counter", "aTargets": [ 10 ] }
],*/
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull )
{
console.log(aData);
if(aData["spam"] === 'Yes'){
$(nRow).css({"background-color":"#FFC2B2"});
}else{
$(nRow).css({"background-color":"#C2E0FF"});
}
return nRow;
},
aoColumns : [
{ "sWidth": "9%"},
{ "sWidth": "9%"},
{ "sWidth": "9%"},
{ "sWidth": "9%"},
{ "sWidth": "9%"},
{ "sWidth": "9%"},
{ "sWidth": "9%"},
{ "sWidth": "9%"},
{ "sWidth": "9%"},
{ "sWidth": "9%"},
{ "sWidth": "9%"}
]
});
};
Does anyone have an idea how to fix this problem?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire