2012-08-22 28 views
0

我有一个使用Jquery表单插件的基本联系表单。我无法使用插件提交它。它只提交如果我添加一个PHP包括process.php。Jquery表单插件没有提交到进程页面

的Javascript:

$(document).ready(function() { 
    $("#contact").validate({ 
     submitHandler: function(form) { 
      $(form).ajaxSubmit({ 
       url:"process.php", 
       type:"post", 
      }); 
     } 
    }); 
}); 

这里是我的联系方式:

<form id="contact" method="post" name="validation" action="contact.php" onsubmit="return validateForm();"> 
    <fieldset> 

     <label for="name">Name</label> 
     <input type="text" name="name" placeholder="Full Name" title="Enter your name" class="required"> 

     <label for="email">E-mail</label> 
     <input type="email" name="email" placeholder="[email protected]" title="Enter your e-mail address" class="required email"> 

     <label for="phone">Phone</label> 
     <input type="tel" name="phone" placeholder="ex. (555) 555-5555"> 

     <label for="message">Question/Comment</label> 
     <textarea name="message"></textarea> 

     <input type="submit" name="submitted" class="button" id="submit" value="Send Message"  /> 

    </fieldset> 
</form> 

Process.php

<?php 
    function GetHeaders() 
    { 
    $headers = 'MIME-Version: 1.0' . "\r\n"; 
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 
    // Additional headers 
    $headers .= 'From: Company Name<[email protected]>' . "\r\n"; 
    return $headers; 
    } 
    // Get Data 
    $name = strip_tags($_POST['name']); 
    $email = strip_tags($_POST['email']); 
    $phone = strip_tags($_POST['phone']); 
    $message = strip_tags($_POST['message']); 
    // Send Message 
    $headers = GetHeaders(); 
    $intro = "\"Thank you for contacting Company Name. We are very interested in assessing your situation and will be in touch as soon possible.\" <br /> 
    <br/> 
     Best Regards,<br/> 
    <br/> 
     Company<br/> 
    "; 
mail($email, "RE: Contact Form Submission", $intro, $headers);  
?> 

感谢提前任何帮助。

+0

什么'process.php'的内容? – Julien

+0

我在上面添加了它,但好像它甚至没有达到process.php。当使用include(“process.php”);我可以让所有的东西都可以工作,但我真的很想掌握为什么表单插件不工作。我也在使用jquery 1.8.0 – user1505573

+0

在html'action ='contact.php''和ajax'url:'process.php''让我感到困惑 – diEcho

回答

0

您需要从表单属性中删除onsubmit="return validateForm();。您已经确认在您的查询功能齐全

而且使用$("#contact").validate({,您的形式似乎是要提交给contact.php,不process.php

action="contact.php" 
+0

谢谢,hsalama--我以为插件覆盖了动作形式,即contact.php?我不希望用户在提交表单后进入process.php,我希望他们留在contact.php上 – user1505573