Reputation: 1
I'm trying to change my routing page in codeiginiter. how can i change my default controller
Someone already do this?
Thanks.
Upvotes: 0
Views: 70
Reputation: 11
By calling Ajax Api in your JavaScript file, you can call controller
for these you can follow below steps -
$.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.");
}
}
});
$route['users/get_client_details'] = 'users/fetch_client_details';
Now you can access your controller from JavaScript.
Upvotes: 1
Reputation: 1731
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)
}
});
Upvotes: 0
Reputation: 4079
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,
Upvotes: 4
Reputation: 2919
Go to the application/config
folder and open routes.php
files and change this line :
$route['default_controller'] = "name_of_your_controller";
Upvotes: 1