Support the ongoing development of Laravel.io →
Requests Eloquent Forms

Hi there, I am trying to integrate jQuery dataTables in my Laravel project but I can't seem to be able to do so.

I have this controller that I make an AJAX request to:

public function getMembers(){ $aaData = Member::take(1)->get(); return json_encode(array("aaData" => $aaData)); }

however, upon getting the request, my "aaData" variable holds an empty array. If I do return Member::all(); I do get my members to my client, but not when I put them in aaData. Otherwise, aaData is a must because datatables expects it.

Anybody please help. I thank you in advance for any help. Thanks

Last updated 2 years ago.
0

This made it work:

$aaData = Member::take(1)->get()->toArray(); return json_encode(array("aaData" => $aaData)); return $return;

thanks to bencohenbaritone for the solution provided in chat.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

bibiki bibiki Joined 27 Apr 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.