0

I'm trying to change my routing page in codeiginiter. how can i change my default controller

Someone already do this?

Thanks.

2
  • 1
    Elaborate more. What have you tried yet? Commented Sep 3, 2014 at 12:07
  • 2
    The title and content dont match??? Commented Sep 3, 2014 at 12:11

4 Answers 4

4

If I understand you well, you wanted to change your default controller.

You can do it in application/config/routes.php

$route['default_controller'] = 'welcome'; // Change welcome with your default controller class,
Sign up to request clarification or add additional context in comments.

Comments

1

Go to the application/config folder and open routes.php files and change this line :

$route['default_controller'] = "name_of_your_controller";

Comments

1

By calling Ajax Api in your JavaScript file, you can call controller

for these you can follow below steps -

  1. first include jQuery in your CodeIgniter project.
  2. Now, Add Ajax call in javascript file

$.ajax({
                url: "users/get_client_details",
                type: "POST",
                data: {"userId": id},
                async: false,
                dataType: 'json',
                success: function (response) {
                    if (response.status === "false") {
                        alert("Please Enter Correct id.");
                    }
                }
            });

  1. Add routes path in routes.php

$route['users/get_client_details'] = 'users/fetch_client_details';

Now you can access your controller from JavaScript.

Comments

0

In the past, I have set up a route for the ajax request. Something like this:

$route['admin/search/(:any)'] = 'admin_controller/admin/do_search/$1';

Then my ajax request would look like this: AJAX Request

$.ajax({
type : 'POST',
data : 'your data',
url : '<?php array('controller'=>'abc','action'=>'you function')?>',
success :   function(data){
           alert(success)
}
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.