In my bootstrap.php I have the following code:
// Check if ajax request
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == "XMLHttpRequest")
{
Route::set('ajax', '(<controller>(/<action>(/<id>)))')
->defaults(array(
'controller' => 'home',
'action' => 'index',
));
}
Route::set('default', '(<controller>(/<action>(/<id>)))')
->defaults(array(
'controller' => 'home',
'action' => 'index',
));
The 'ajax' route is incomplete. What I want to do is if the request is done via. ajax, then Kohana should look for the controller in a subfolder within my controllers called ajax/. So, if ajax request then:
http://localhost/myproject/somecontroller/someaction routes to somecontroller inside the ajax subfolder. If not ajax then just use the 'default' route.