jQuery AJAX form using mail() PHP script sends email, but POST data from HTML form is undefined

前端 未结 6 1625
青春惊慌失措
青春惊慌失措 2020-11-27 05:07

Thanks for taking the time to look, guys. I\'m creating a pretty basic AJAX contact form using jQuery. The email sends, but upon opening the email there is no POST data, so

6条回答
  •  野性不改
    2020-11-27 05:44

    You code should be:

       
    

    Js

    var data = {
        name: $("#form_name").val(),
        email: $("#form_email").val(),
        message: $("#msg_text").val()
    };
    $.ajax({
        type: "POST",
        url: "email.php",
        data: data,
        success: function(){
            $('.success').fadeIn(1000);
        }
    });
    

    The PHP:

    
    

提交回复
热议问题