How to call controller function in codeigniter?
// to call the controller function from the view, do $controller->myOtherFunct(); Codeigniter is an MVC (Model – View – Controller) framework. It’s really not a good idea to call a function from the view.
Table of Contents
How do I call a Javascript controller?
Call controller action with parameter… See:
- ps get(“/Home/SaveEmployeeRecord”, {id:’67’,name:’Deepak’}, function (data) {
- alert(data.id); // show the id value that is returned from the action method.
- alert(data.name);//displays the value of the name that is returned from the action method.
- });
How do I make a CI controller?
CodeIgniter allows you to do this. Just create sub-directories under main app/controllers/one and put your controller classes inside them. Each of its subdirectories can contain a default handler that will be called if the URL contains only the subdirectory.
How do you call a controller method from HTML?
3 answers
- Controllers/RegistrationController.cs.
- Views/Registration/Detail.cshtml @using (Html.BeginForm(“Detail”, “Registration”, FormMethod.Post, new { @onSubmit = “return validateForm();” })) { // The content of your form }
How do I call a method from another class in CodeIgniter?
How to call model function from another model in Codeigniter?
- Create model file Model_1:
- application/models/Model_1.php.
- application/models/Model_2.php.
- Create Route:
- application/config/routes.php.
- Create base controller:
- application/controller/BaseController.php.
How do I redirect in CI?
The redirect() function is used for this purpose… CodeIgniter – Page Redirection.
Syntax | redirect($uri = ”, $method = ‘auto’, $code = NULL) |
---|---|
Parameters | $uri (string) − URI string $method (string) − Redirect method (‘auto’, ‘location’, or ‘update’) $code (string) − HTTP response code (usually 302 or 303) |
return type | empty |
How to call CodeIgniter controller function from view?
You can call a controller function with AJAX on your view. In this case, I’m using the jQuery library to make the call. This way you can create code chunks (modules) and reload them with AJAX method in an HTML container. views cannot call controller functions.
Why is my CodeIgniter not working in JavaScript?
This doesn’t work in my codeigniter function. I have the ID and I can’t get that ID. Please help me. this is my view and i am trying to send my id via function. Thanks for contributing an answer to Stack Overflow!
How to call CI controller from JS?
Calling CI Controller from JS without reloading the page would require an AJAX request more or less. You can use what NeoArc suggests, use jQuery because it has great syntax and has AJAX included. This is sample code for your problem. Code:
When to call a function in a controller?
When I call the function in a controller, I get a 404 page. Codeigniter is an MVC (Model – View – Controller) framework. It’s really not a good idea to call a function from the view. The view should be used for presentation only, and all your logic should be happening before you get to the view in the controllers and models.