DataTables and Laravel - can't get them to talk to each other properly
DataTables and Laravel - can't get them to talk to each other properly
mcgrevy
Posts: 35Questions: 0Answers: 0
This could be either a DataTables problem or a Laravel one. I just don't know. I am new to them both. I have both working stand alone now I want them to interact. I want to get my data from a Laravel source.
In a nutshell my problems is that I can get to the Laravel routes.php but I don't have the required info to route to my controllers, I can only get the default home page.
In DataTables I have
[code]
bProcessing: true,
bServerSide: true,
sAjaxSource: "http://opm.picturenet.co.za/laravel/public_html/index.php",
"fnServerData": function ( sSource, aoData, fnCallback ) {
$.ajax( {
"dataType": 'json',
"type": "GET",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
},
[/code]
In Laravel I have
[code]
echo 'bla bla';
Route::get('/', function()
{
return View::make('home.index');
});
//Named Route
Route::get ('types', array('uses'=>'types@index', 'as'=>'types'));
[/code]
I get the 'bla bla' display so the sAjaxSource is at least right but I have no routing info.
I have tried
sAjaxSource: "http://opm.picturenet.co.za/laravel/public_html/index.php/types",
sAjaxSource: "http://opm.picturenet.co.za/laravel/public_html/index.php?types",
sAjaxSource: "http://opm.picturenet.co.za/laravel/public_html/index.php?route=types",
but I either get a 404 or else the home page
Can anyone who has done this give me some sample code?
As a note. I had a lot of trouble with Laravel and 404 errors when I first tried Laravel but I got it right so if you tell me it is about .htaccess and mod_rewrite again I won't be suprised but I can find no errors there at present.
I just need to know what parts of my code are OK. I just don't know at present so don't know what to look for. Disappearing up my own fundamental orifice.
In a nutshell my problems is that I can get to the Laravel routes.php but I don't have the required info to route to my controllers, I can only get the default home page.
In DataTables I have
[code]
bProcessing: true,
bServerSide: true,
sAjaxSource: "http://opm.picturenet.co.za/laravel/public_html/index.php",
"fnServerData": function ( sSource, aoData, fnCallback ) {
$.ajax( {
"dataType": 'json',
"type": "GET",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
},
[/code]
In Laravel I have
[code]
echo 'bla bla';
Route::get('/', function()
{
return View::make('home.index');
});
//Named Route
Route::get ('types', array('uses'=>'types@index', 'as'=>'types'));
[/code]
I get the 'bla bla' display so the sAjaxSource is at least right but I have no routing info.
I have tried
sAjaxSource: "http://opm.picturenet.co.za/laravel/public_html/index.php/types",
sAjaxSource: "http://opm.picturenet.co.za/laravel/public_html/index.php?types",
sAjaxSource: "http://opm.picturenet.co.za/laravel/public_html/index.php?route=types",
but I either get a 404 or else the home page
Can anyone who has done this give me some sample code?
As a note. I had a lot of trouble with Laravel and 404 errors when I first tried Laravel but I got it right so if you tell me it is about .htaccess and mod_rewrite again I won't be suprised but I can find no errors there at present.
I just need to know what parts of my code are OK. I just don't know at present so don't know what to look for. Disappearing up my own fundamental orifice.
This discussion has been closed.
Replies
Allan
Allan
I saw the library but want to figure it out for myself before I use it (or not).
I modified fnServerData in my search for a solution but will now revert. Thanks for heads up.
I found the problem. I had the Laravel folder inside the public_html folder of DataTables, As soon as I put DataTables inside Laravel the whole lot worked in the way I was expecting. Gotta be something with my paths but will nail it down later.
The sAjaxSource must specify the name of the Laravel named route and not the index file so now my mind is right on that point.
It looks like the combo of DataTables and Laravel are going to yield a very neat extensible solution to my clients needs. Well done to you and the Laravel people :) :) :) all round.