jquery is not bringing the value of the form

0

I have this script that makes a request for a php page, the problem is that it is not bringing the input value to the php file. How could I solve this?

php

$mail->MsgHTML('corpo do email'. $_POST['email'].''); 

jquery

$(document).on('click', '#reg-form_planejamento input[type="submit"]', function(e){
    e.preventDefault(); 

    $.ajax({
        url: 'email_planejamento.php',
        type: 'POST',
        data: $(this).serialize() 
    })
    .done(function(data){
        $('#form-content_2').fadeOut('slow', function(){
            $('#form-content_2').fadeIn('slow').html(data);
        });
    })
    .fail(function(){
        alert('Ajax Submit Failed ...');    
    });
});

HTML

<form action="email_planejamento.php" id="reg-form_planejamento" method="post" class="wpcf7-form" novalidate>
<div style="display: none;">
<input type="hidden" name="_wpcf7" value="6">
<input type="hidden" name="_wpcf7_version" value="4.9.2">
<input type="hidden" name="_wpcf7_locale" value="en_US">
<input type="hidden" name="_wpcf7_unit_tag" value="wpcf7-f6-p1065-o1">
<input type="hidden" name="_wpcf7_container_post" value="1065">
</div>
<div class="digite_email">
<span class="wpcf7-form-control-wrap email"><input type="text" name="email" value="" size="40" class="wpcf7-form-control wpcf7-text wpcf7-validates-as-required" aria-required="true" aria-invalid="false" placeholder="Digite seu e-mail"></span>
</div>
<div class="assinar">
<input type="submit" value="SABER MAIS" class="wpcf7-form-control wpcf7-submit">
</div>
<div class="wpcf7-response-output wpcf7-display-none"></div></form>
    
asked by anonymous 02.01.2018 / 20:39

1 answer

1

You are serializing a context that is not the form. To serialize the form, do so (change your this by the form):

var form = $('#reg-form_planejamento');

$.ajax({
    url: 'email_planejamento.php',
    type: 'POST',
    data: form.serialize() 
})
    
02.01.2018 / 20:45