Ajax By Form Data= Variable Undefined

Asked

Viewed 116 times

0

This is my form

<form action='emails.php' method='post' >
<input type='submit' value='Enviar para Email Selecionados'  class='selecionados'/>

</form>


<div class='divtop' style='display:none; '>
<form method='post' action='recebedor.php' enctype="multipart/form-data" id='novo'>
Remetente(Seu Email ou qualquer outro):<br>
<input type='text' name='remetente'  style='width:100px;' />
<br>

Assunto do Email(Título):<br>
<input type='text' name='assunto' class='assuntoo' style='width:100px;' />
<br>
Mensagem:
<br>
<textarea class='mensagemdotext' name='mensaginha' ></textarea>
<br>
Deseja anexar uma imagem após a mensagem?:
<div class='sim'><input type='radio' name='resposta' />SIM </div>
<div class='nao'><input type='radio' name='resposta'> NÃO</div>
<input type='file' class='arquivo' name='arquivu' />
<br><br>
Destinatários(Clientes):
<div class='destinarios'>
<ul>

</ul>

</div>
<input type='submit' value='Enviar Email Agora' />
</div>
</form>

This is my script

$('#novo').on('submit',function(e) {
        e.preventDefault();

        var form = document.getElementById('#novo');
        var dados = new FormData(form);

    $.ajax({
        url:'recebedor.php',
        type:'post',
        data:dados,
        contentType:false,
        processData:false,
        success:function(resp) {
                alert(resp);
        }

    });

    });

The problem is right after the ajax request I get this message: inserir a descrição da imagem aqui

  • Code images, not good, could switch to code tag and put code straight instead of images ... if you can do it better.

1 answer

1


According to the documentation, the method getElementById returns the element reference through your ID, so you have no reason to use hashtag.

var form = document.getElementById('novo');

But you can use the method querySelector

var form = document.querySelector('#novo');
  • Rapazzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz would never find the error, is programming hard right? A web programmer can earn 1000 a month? I’m studying to be a , mt thank you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.