Welcome Guest, Not a member yet? Register   Sign In
Call controller function outer folder
#1

(This post was last modified: 02-04-2016, 02:49 PM by slipdiegoknot.)

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() {
                $.ajax({
                    url  : 'c_inner_ctrl/function_works',
                    async: false,
                    type : 'POST'
                 })
                 .done(function(data){
                    console.log(data);
                 });
            }
this one doesn't

Code:
function probar() {
                $.ajax({
                    url  : 'c_main/function_doesnt_work',
                    async: false,
                    type : 'POST'
                 })
                 .done(function(data){
                    console.log(data);
                 });
            }
Reply


Messages In This Thread
Call controller function outer folder - by slipdiegoknot - 02-03-2016, 03:10 PM



Theme © iAndrew 2016 - Forum software by © MyBB