I've changed the following files:
app/Config/Autoload.php (added 'Modules')
Code:
$psr4 = [
'Config' => APPPATH . 'Config',
APP_NAMESPACE => APPPATH, // For custom namespace
'App' => APPPATH, // To ensure filters, etc still found,
'Modules' => ROOTPATH.'modules'
];
app/Config/Routes.php
Code:
$routes->group('navigation', ['namespace' => 'Modules\Navigation\Controllers'], function($routes)
{
$routes->get('/', 'NavigationController::index');
$routes->get('getnavigationitems', 'NavigationController::getNavigationItems');
});
The issue I am having is that if I do a simple jQuery ajax POST request like this, it fails:
Code:
$(document).ready(function(){
$.post('navigation/getnavigationitems',{group:'admin'},function(response){
console.log(response);
})
})
I get "Controller or its method is not found: App\\Controllers\\Navigation::getnavigationitems"
But if I do the same request by changing $.post to $.get like this, it works:
Code:
$(document).ready(function(){
$.get('navigation/getnavigationitems',{group:'admin'},function(response){
console.log(response);
})
})
No other default codeigniter 4 files have been modified. What am I doing wrong?