Codeigniter Form Ajax - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: Codeigniter Form Ajax (/showthread.php?tid=54949) |
Codeigniter Form Ajax - El Forum - 10-02-2012 [eluser]ninjayan[/eluser] Hi everyone. I'm just new to CodeIgniter. I was following different tutorials creating a form with validation and now, I want to create a form which utilizes jQuery+Ajax. So I have this code right now. view: login Code: [removed] controller: main/login_validation Code: public function login_validation() { model: user_model Code: public function validate() { Now, when I click login without inputs or any of the fields the validation is ok. If the user is not found, it also returns a message and it is ok. But my problem is, when the user is validated and exist, it should redirect to redirect(base_url('site/dashboard')); but its not. Please help me. Thanks! Codeigniter Form Ajax - El Forum - 10-02-2012 [eluser]CroNiX[/eluser] Code: redirect('controller/method'); Codeigniter Form Ajax - El Forum - 10-02-2012 [eluser]ninjayan[/eluser] Thank you for the reply. Another question. How can I pass a variable from model to controller? thanks Codeigniter Form Ajax - El Forum - 10-03-2012 [eluser]spfortier[/eluser] You could create a "get" function in your model and set the private variable to whatever it is you want to pass to the controller, like this: Code: private $test_var; Then in your controller: Code: $test_var = $this->user_model->getTestVar(); Codeigniter Form Ajax - El Forum - 10-03-2012 [eluser]ninjayan[/eluser] Oh. Thank you. Codeigniter Form Ajax - El Forum - 10-03-2012 [eluser]ninjayan[/eluser] by the way, why do i need to use private in Code: private $test_var; Codeigniter Form Ajax - El Forum - 10-03-2012 [eluser]spfortier[/eluser] You don't necessarily need to use private, it just provides a level of security to keep you from accidentally overwriting the value stored in the variable as it hides the variable from anything outside the class. It also promotes a better programming style. I generally use "getters" and "setters" to pass values to and from my models. Code: class Test { |