ajax正在工作,但表单数据未提交

im using a ajax contact form that fades out and shows a thank you message.And I also get the mail after i submit the form.But it doesn't have any data that is entered in the form.I think the form data is not getting passed on to handler.php..Any helps please?

ajax.js

$(function() {

var theForm = $("#memberform");

theForm.validate({

submitHandler: function(theForm) {

$('#loader', theForm).html('Please Wait...');

$.ajax({
type: "POST",
url: "handler.php",
data: $(theForm).serialize(),
timeout: 20000,

    success: function(msg) { $(theForm).fadeOut((500, function(){ 

                $(theForm).html("<h2>Thank you. We will contact you shortly.</h2>").fadeIn(); 

                }));
            },

            error: $('.thanks').show()

        });

        return false;
    }
   });
});

handler.php

<?php


$to      = 'something@gmail.com';
$subject = 'Contact Form';

$name = $_POST['senderName'];
$phone = $_POST['senderNumber'];
$email = $_POST['senderEmail'];
$message = $_POST['senderComments'];

$MESSAGE_BODY = "Name: ".$name."<br>"; 
$MESSAGE_BODY .= "Contact No: ".$phone."<br>"; 
$MESSAGE_BODY .= "Email: ".$email."<br>"; 
$MESSAGE_BODY .= "Message: ".nl2br($message)."<br>"; 

$headers  = 'MIME-Version: 1.0' . "
";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "
";

// Additional headers
$headers .= 'From: Companyname' . "
";
$headers .= 'Reply-To: something.com' . "
";
$headers .= 'Cc: something@gmail.com' . "
";
//$headers .= 'Bcc: example@example.com' . "
";


mail($to, $subject, $MESSAGE_BODY, $headers);


?

scripts i linked in head tag on top of the body tag.

<script src="js/jquery-3.1.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery.validate.min.js"></script>
<script type="text/javascript" src="ajax.js"></script>
<script type="text/javascript" src="met.js"></script>

and I edited the web.config file with the rewrite rule to hide .php extentions from domain...

<rewrite>
        <rules>
    <rule name="Hide .php ext">
        <match ignoreCase="true" url="^(.*)"/>
        <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
            <add input="{REQUEST_FILENAME}.php" matchType="IsFile"/>
        </conditions>
        <action type="Rewrite" url="{R:0}.php"/>
    </rule>
    <rule name="Redirecting .php ext" stopProcessing="true">
        <match url="^(.*).php"/>
        <conditions logicalGrouping="MatchAny">
            <add input="{URL}" pattern="(.*).php"/>
        </conditions>
        <action type="Redirect" url="{R:1}"/>
    </rule>
   </rules>
</rewrite>

Try this , maybe helpful

$(function() {
var theForm = $("#memberform");
var data =  theForm.serialize();
theForm.validate({
    submitHandler: function(theForm) {
        $('#loader', theForm).html('Please Wait...');
        $.ajax({
            type: "POST",
            url: "handler.php",
            data: data,
            timeout: 20000,
            success: function(msg) { $(theForm).fadeOut((500, function(){ 
                    $(theForm).html("<h2>Thank you. We will contact you shortly.</h2>").fadeIn();
                }));
            },
            error: $('.thanks').show();
        });return false;
    }
   });
});

Thanks for helping me with the problem.Just found the answer by deleting some rewrite rule.The problem is in web.config.Removing the rewrite rule makes the form work just fine...

Or if you want to keep the rewrite rule and submit the form, edit the ---url: "handler.php"--- line to url: "handler" and the form works just fine.