I’m a newbie to ajax and trying to integrate it in to my CodeIgniter app. Basically, when the form is successful I would like the original template to be hidden and the new one shown? It currently displays both, how could I amend my code? Thanks in advance!
I have tried adding a redirect to my controller with no such luck 🙁
view:
$('#submit').click(function(){
$.post("<?php echo base_url(); ?>part-two",
$("form").serialize(),
function(result){
$("#error_message").html(result);
}, "html"
);
});
controller:
if($this->form_validation->run() == FALSE){
echo validation_errors();
} else {
echo "success";
$data['content'] = "part_two";
$this->load->view('template', $data);
}
OK, I think that I know what you want…
View html markup:
Script: