0
I have several forms in an html, and I want to send with Ajax each form, I am using serialize(). But it’s not working out where I’m going wrong?
<div class="resultado_<?php $i++; echo $i ?>">
<span class="bom"><br>Cadastro Completo</span><br>
<form method="post" id="favoritos" novalidate="novalidate">
<input type="hidden" name="id_empresa" value="<?php echo $row["id"]?>" class="id_empresa">
<input type="submit" value="Favoritos">
</form>
</div>
Ajax
$(Document). ready(Function() { $("#favorites"). Submit(Function() {
$.ajax({
type: "POST",
url: 'enviar_atualizar.php',
data: $(this).serialize(),
success: function (data) {
// Inserting html into the result div
$('.resultado_'+formID).html(data);
},
error: function(jqXHR, text, error){
// Displaying if there are any errors
$('.resultado_'+formID).html(error);
}
});
return false;
});
});
returns this on the console
Uncaught Referenceerror: formID is not defined
edited my reply, is returning an error on the console
– Wagner Martins Bodyboard
@Wagnermartinsbodyboard formID was not defined, where should this var come from? Give details.
– Guilherme Nascimento