2
I’m having a problem making the deletion attempt and I get an error message on the console, my script is like this:
<form action="" id="frmDeleta" class="smart-form">
<button type="submit" class="btn btn-danger"> Excluir </button>
<input name="IdEvento" type="hidden" value="<?php echo $IdEvento; ?>">
</form>
$(document).ready(function () { $("#frmDeleta")({ // NÃO ALTERAR O CÓDIGO errorPlacement: function (error, element) { error.insertAfter(element.parent()); }, submitHandler: function (form) { var data = $(form).serialize(); // console.log(data); $.ajax({ type: 'POST', url: 'pDeletaAgendamento.php', data: data, dataType: 'json', beforeSend: function () { $("#msgResult").html('×AVISO! Enviando...'); }, success: function (response) { if (response.codigo == "1") { $("#msgResult").html('×AVISO!' + response.mensagem + ''); // RESETANDO O FORMULÁRIO APÓS GRAVAÇÃO $('#frmDeleta').each(function () { this.reset(); }); } else { $("#msgResult").html('×ATENÇÃO! ' + response.mensagem + ''); } }, error: function (xhr, ajaxOptions, thrownError) { // console.warn(xhr.responseText); console.log(xhr, ajaxOptions, thrownError); $("#msgResult").html('×ATENÇÃO! Ocorreu um erro ao tentar enviar o Agendamento. Contate o departamento de TI.'); } }); return false; } }); });
But on my console I’m getting the following message:
Have you checked if jquery is started correctly? By the error you are saying that
$(...)
is not a function.– Erlon Charles
You need to add the
jQuery
before executing theajax
– Kenny Rafael
#frmDeleta
refers to thename
of the objectform
, not to theid
– MarceloBoni
I am starting Jquery @Erloncharles and Kenny Rafael correctly
– adventistapr
I hadn’t really noticed this bit:
$("#frmDeleta")({
, need to add some method like the$("#frmDeleta").submit({
for example, not that this deserves an answer, small syntax error, however the question is that you will have other errors in your script, keep updating there.– Kenny Rafael