Skip to content Skip to sidebar Skip to footer

Codeigniter - Error On Ajax Call (404)

I have a service running for static pages on CodeIgniter and now I want to make it dynamic using Ajax calls, but the Ajax call always returns as 404 error (defined by the alert on

Solution 1:

Comments from @Dimi showed me what was going on: the use of underscores on the start of functions' names, e.g. _function_one doesn't work; function_one does work, makes CodeIgniter break.

The solution I came up with was to rename the function to the format function_one (get_procs, on my case) and create a rule on the routes.php config file:

$route['controller/_get_procs'] = 'controller/get_procs';

This is a workaround to make it work without changing the default configuration of CodeIgniter. I don't know if there is another way.

As pointed out by @cssBlaster21895, CodeIgniter follows up PHP Coding Style (see more here), which determines _function as a private function.

Post a Comment for "Codeigniter - Error On Ajax Call (404)"