Good afternoon, I'm a beginner in development.
I have a form that I do not want the page not to be reloaded when the user submits the form. I am using Ajax, I have been able to perform the inclusion in the database using codeigniter + ajax, but the ajax success statement is not being invoked, I would like to know how to invoke it,
Controller
public function agendar()
{
$data['nome'] = $this->input->post('nome');
$data['email'] = $this->input->post('email');
$data['celular'] = $this->input->post('celular');
$data['dia'] = $this->input->post('dia');
$data['hora'] = $this->input->post('hora');
echo $this->db->insert('agenda',$data);
}
Ajax
$("#formulario").submit(function(event){
event.preventDefault();
$.ajax({
url: 'http://localhost/Odontologia/odonto/agendar',
type: 'POST',
data: {
nome: $('#nome').val(),
email: $('#email').val(),
celular: $('#txttelefone').val(),
dia: $('#dia').val(),
hora: $('#hora').val()
},
sucess: function() {
alert('teste');
}
});
});