Call controller function outer folder |
Hi friends I have a controller inside a folder but I can't call a function from a controller in a parent folder using AJAX.
(codeigniter 3.0.0) application ----controllers c_main.php cf_folder -------c_inner_ctrl.php ----views ----my_view.php public ----js ----jslogic.js So c_inner_ctrl loads the view called my_view ($this->load->view->('my_view')) The view (my_view) imports a javascript file called jslogic.js is this JS file there is a function that calls a function from c_inner_ctrl.php and it works fine. NOW! if from this very JS file I want to call a function in c_main.php I get the error in google chrome's console POST http://localhost/my_project/cf_folder/c_main 404 (Not Found) This means that I am not able to call a CONTROLLER function from another view which its controllers is in another folder Here is the js function (this one works) Code: function probar() { Code: function probar() {
Your error message provides a clue to the problem ... you are linking to c_main inside the cf_folder, where your c_inner_ctrl is.
You should be linking one folder higher. You have misread/misunderstood the error message, and are drawing an inappropriate conclusion. If you set up virtual hosting, mapping a local domain to your htdocs/my_project, then your link references could be absolute, i.e. "/cf_folder/c_inner_ctrl" and "/c_main".
(02-03-2016, 05:23 PM)ciadmin Wrote: Your error message provides a clue to the problem ... you are linking to c_main inside the cf_folder, where your c_inner_ctrl is. Hi! how do I do that? If I write in the url parameter: 'c_main/function_doesnt_work' it produces the error I described. If I try that something concats my url value to the folder I am already in and produces cf_folder/c_main where cf_folder is the folder where I am and concats c_main (the controller I am aiming) I cannot point to a controller in a higher folder.
|
Welcome Guest, Not a member yet? Register Sign In |