Following is route:
$router->get('/securityquestionlist', [ 'as'=> 'SecurityQuestionListIndexRoute', 'uses'=> 'SecurityQuestionListController@index']);
I have following action in controller class:
public function index()
{
$model = new SecurityQuestionListModel();
$data = $model->select('question','created_at', 'updated_at', 'status')->where('status', 1)
->orderBy('created_at', 'desc')
->paginate(3);
if(Request::ajax()){
return response()->json(['rData' => $data]);
}else{
return view('securityquestionlist.index' /* ,['rData'=> $data]*/ );
}
Following is Ajax code:
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('#IdSQLTable').DataTable({
'ajax' : 'http://localhost:9901/securityquestionlist',
'cache' : false
});
} );
</script>
I am receiving following AJAX response from server:
{"rData":{}}
Can some one guide me, in case of AJAX why $data value is not returning from server. If I disable ajax, and load normal page then value is received on client side and table rows are populated with data. Right now I have made it remarks in :
return view('securityquestionlist.index' /* ,['rData'=> $data]*/ );
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire