JQUERY SUBMIT HANDLER导致错误

时间:2017-07-27 07:22:24

标签: javascript php jquery ajax

这只是一段代码...但它没有向相应的PHP文件发布任何值。我使用print_r语句检查...

我尝试了自己的想法......我将不再工作了......

任何可能性?

等待解决方案......

提前致谢。

FORM (更新)

<form method="post" id="book-appointment">

  <input name="name" type="text" id="name" onfocus="if (this.value==this.defaultValue) this.value = &#39;&#39;" 
         onblur="if (this.value==&#39;&#39;) this.value = this.defaultValue" placeholder="Name" />
  <br />

  <input name="phone" type="text" id="phone" placeholder="Phone" 
         onfocus="if (this.value==this.defaultValue) this.value = &#39;&#39;"
         onblur="if (this.value==&#39;&#39;) this.value = this.defaultValue" />
  <br />

  <input name="email" type="text" id="email"
         onfocus="if (this.value==this.defaultValue) this.value = &#39;&#39;" 
         onblur="if (this.value==&#39;&#39;) this.value = this.defaultValue" placeholder="Email" />
  <br>          
  <input type="submit" value="ENQUIRE NOW" class="btn btn-block has-spinner" style="background: #c2002f; color: #ffffff;
                              font-weight: normal; text-transform: uppercase; border-bottom: none; margin: 10px 0px;
                              padding: 12px 0 10px 0px;" />
  <div class="alert" style="text-align: center;padding: 8px;display: none;" id="alert_enquiry">Please Wait...</div>
</form>

JAVASCRIPT文件:

$(document).ready(function () {
    $("#book-appointment").validate({
        rules:
                {
                    name: {
                        required: true
                    },
                    email: {
                        required: true,
                        email: true
                    },
                    phone: {
                        required: true,
                        number: true
                    }
                },
        messages:
                {
                    name: "Please enter your name",
                    email: "Please enter the mail address",
                    phone: "Please enter the phone number",
                },
        submitHandler: submitForm
    });
    function submitForm()
    {
        var data = $("#book-appointment").serialize();
        var url = "user_detail.php";
        $.ajax({
            type: 'POST',
            url: url,
            data: data,
            success: function (data) {
                var btn = $(this);
                $(btn).buttonLoader('start');
                setTimeout(function () {
                    $(btn).buttonLoader('stop');
                }, 3000);
                setTimeout(function () {
                    //windows.location.href="thank.php";
                    window.location.href = 'thankyou.php';
                }, 2000);

                $('#name').val('');
                $('#phone').val('');
                $('#email').val('');
            }
        });
    }
});

我找不到问题。?

0 个答案:

没有答案