I am creating a land-page for capturing leads. I need to pass the files via ajax so I do not have to redirect the page, however whenever I send the data to the page that must include the database it tries to redirect the page to a course page or something. As Ajax is not my strong, I need your help to know where the error is.
I think it's important to point out that the site is made in wordpress.
How can I solve this problem?
$("#submit").submit(function (e){
e.preventDefault();
$("#submit").val('Enviando...');
$.ajax({
url: 'process.php',
type: 'post',
dataType: 'html',
data: {
'metodo': $('#metodo').val(),
'nome': $('#nome').val(),
'sobrenome': $('#sobrenome').val(),
'email': $('#email').val(),
'telefone': $('#telefone').val(),
'curso': $('#curso').val()
}
}).done(function (data){
alert(data);
$("#submit").val('Enviar');
$('#nome').val('');
$('#sobrenome').val('');
$('#email').val('');
$('#telefone').val('');
$('#curso').val('');
});
});
<form class="cata-lead">
<div class="lp-titulo">
Preencha este formulário e garanta seu futuro entre os <obs>melhores</obs>.
</div>
<div class="item-cata-lead">
<input type="text" name="nome" id="nome" placeholder="Primeiro Nome*"/>
<input type="text" name="sobrenome" id="sobrenome" placeholder="Sobrenome*"/>
<input type="email" name="email" id="email" placeholder="E-mail*"/>
<input type="tel" name="telefone" id="telefone" placeholder="Telefone*"/>
<select name="curso" id="curso">
<!--Laço para preenchimento dos cursos disponíveis-->
<option>Curso de interesse*</option>
<?php
foreach ($cursos as $curso):
?>
<option value="<?php echo utf8_encode($curso['nome']); ?>">
<?php echo utf8_encode($curso['nome']); ?>
</option>
<?php
endforeach;
?>
</select>
<input type="hidden" id="metodo" value="metodo">
<input type="submit" id="submit" name="submeter" value="Estou interessado!">
</div>
</form>