Message while form is being sent

0

Good evening guys, I have a form in php that with the option to attach file and then it will be sent to an email, I am beginner in this part of ajax and javascript but would like to know if it has how to display a message while the form is "sent" if it is javascript or only with ajax, if anyone has examples thanks

 <form method="post" action="script/trab_send.php" id="form_trab" onsubmit="return validar(this)" autocomplete="off" enctype="multipart/form-data">
                        <input type="text" class="box" placeholder="NOME*" id="nome" name="nome" pattern="[A-Za-zÀ-úÂ-ûÃ-õ]+$" required>
                        <input type="email" class="box" placeholder="E-MAIL*" name="email" required>
                        <input type="tel" class="box" placeholder="TELEFONE*" name="fone" required pattern="\([0-9]{2}\) [0-9]{4}-[0-9]{4,5}$" OnKeyPress="mascara(this)" maxlength="15">
                        <input id="fakeupload" name="fakeupload" class="fakeupload" type="text" placeholder="ANEXAR ARQUIVO" />
                        <input id="realupload" name="realupload" class="realupload" type="file" progress onchange="this.form.fakeupload.value = this.value;" />
                        <input type="submit" value="Enviar" class="btn-ajuda">
                    </div>
                </form>
            <div class="resposta"></div> '=$_FILES['realupload'];

$mail = new PHPMailer();

$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPDebug = 0;
$mail->Port = 587;
$mail->CharSet = 'UTF-8';
$mail->Host = '';
$mail->Username = '';
$mail->Password = '';
$mail->SetFrom('');
$mail->AddAddress('');
$mail->Subject = '';
$mail->IsHTML(true);
$mail->Body=$body;
$body = "<strong>Arquivo: </strong>{$arquivo['name']}";

$mail->MsgHTML($body);
$mail->AddAttachment($arquivo['tmp_name'], $arquivo['name']);



 if($mail->Send()){
echo "<div class='sucesso'>Formulário enviado com sucesso! Em breve entraremos em contato!</div>";

$(document).ready(function(){
        $(".resposta").hide();
        $("#form_trab").ajaxForm({
            target: '.resposta',
            success: function(retorno){
                $(".resposta").html(retorno);
                $(".resposta").show();
            }
    });'
    
asked by anonymous 06.09.2016 / 06:06

1 answer

0

Add a div with the "message" id

$ ("# form_trab"). on ("subimit", function () {   $ ("# message"). html ("The Form is being sent."); })

    
06.09.2016 / 21:44