[eluser]babazumbula[/eluser]
Hi there,
On home page I have login form and ajax poll. So controller is:
Code:
<?php
class Login extends Controller{
function index(){
$this->load->view('login_form_view');
}
function validate_credentials(){
$this->load->library('form_validation');
$this->load->model('membership_model');
$this->form_validation->set_rules('username','Username','callback_correct_credentials');
if($this->form_validation->run() == false){
$this->index();
}
At this point login and ajax poll work fine, but when they submit incorrect credentials
Code:
$this->form_validation->run()
returns false, so
takes place and error is displayed right under the login form. At this point ajax poll won't work anymore. When "vote" button is clicked nothing happens. Here is jQuery code:
Code:
$(document).ready(function(){
$("#poll #submit").click(function () {
var val = $('input:radio[name=vote]:checked').val();
$("#poll").html('Retrieving...');
$.ajax({
type: "POST",
data: "data=" + val,
url: "<?php echo base_url();?>login/poll/",
success: function(msg){
$("#poll").html(msg)
}
});
});
});
For sake of clarity I'm presenting only essential code, which works when url is: login/index.php , but doesn't if url is: login/validate_credentials. I wonder why is so, since both url load the same view?