0

我從來沒有創建過聯繫表,並且在得到這個提交出於某種原因的問題。它證實罰款,但當我點擊提交,它什麼都不做。沒有錯誤。沒有。我一直在爲此工作12個多小時,對於我的生活我無法弄清楚什麼是錯的。這裏是包含AJAX代碼的jQuery代碼。阿賈克斯沒有提交聯繫表

$(document).ready(function() { 
    $("#form1").validationEngine({ 
     ajaxSubmit: true, 
     ajaxSubmitFile: "ajaxSubmit.php", 
     ajaxSubmitMessage: "Thank you, We will contact you soon !", 
     inlineValidation: false, 
     success: function() { 
      callSuccessFunction() 
     }, 
     failure: function() {} 
    }) 
}); 

這裏是html頁面

<form class="form" id="form1" method="post" action="ajaxSubmit.php"> 
    <input class="validate[required,custom[onlyLetter],length[0,100]] text-input" type="text" name="name" id="name" placeholder="How may I address you?"><label for='name '>name</label><br /> 
    <input class="validate[required,custom[email]] text-input" type="text" name="email" id="email" placeholder="I promise, I hate spam as much as you do."><label for='email '>email</label><br /> 
    <input class="validate[required,length[0,100]] text-input" type="text" name="budget" id="budget" placeholder="$USD amount, please."><label for='budget '>budget</label><br /> 
    <textarea name="message" class="validate[required,length[6,300]] text-input" id="comment" placeholder="What's on your mind?"></textarea><br /> 
    <p class="submit"><input type="submit" value="Send"></p> 
</form> 

對代碼的形式而這是「ajaxSubmit.php代碼完全

<?php 

$name = $_POST['name']; 
$email = $_POST['email']; 
$budget = $_POST['budget']; 
$body = $_POST['text']; 
$receiver = "[email protected]"; 
if (!empty($name) & !empty($email) && !empty($body)) { 
    $body = "Name:{$name}\n\nBudget :{$budget}\n\nComments:{$body}"; 
    $send = mail($email, 'Contact Form Submission', $body, "From: {$email}"); 
    if ($send) { 
     echo 'true'; 
    } 

} 

?> 

我拉我的頭髮在這裏,因爲我真的想要這個特定的表單工作,並且我SOOOOOO關閉。我喜歡它在同一頁上驗證的方式,而不是在用戶試圖提交不正確填寫的表單後,我真的不想我的我因爲他們沒有輸入任何內容,或輸入了錯誤信息,因此輸入了整個電子郵件。

+0

謝謝編輯Shinosha。不幸的是,這種形式仍然不起作用。任何想法爲什麼? – Naomi

回答

0

尋找到它之後,還,還有另一種錯誤,一定要去給你造成麻煩。您的表單包含一個名爲

name, email, budget, message 

很遺憾,你的PHP頁面尋找一個名爲字段的字段

name, email, budget, text 

你的PHP腳本是不會能夠找到一個名爲「文本」字段,如此看來可能您的表單實際上正在提交,但是您的PHP腳本並未返回讓庫認爲完全完成所需的「真實」。如果您修復了郵件/文本命名問題,則應該更接近工作往返。

0

假設您使用的是2.6.1版本的jquery-validation-engine,沒有「onlyLetter」,您需要將其更改爲「onlyLetterSp」。

<input class="validate[required,custom[onlyLetter],length[0,100]] text-input" type="text" name="name" id="name" placeholder="How may I address you?"><label for='name '>name</label><br /> 

<input class="validate[required,custom[onlyLetterSp],length[0,100]] text-input" type="text" name="name" id="name" placeholder="How may I address you?"><label for='name '>name</label><br /> 
+0

嘿@SheldonGriffin。謝謝回覆。這是我沒有包括在頂端的腳本。我認爲它使用的是舊版本的jQuery。 1.3,對嗎? \t \t \t \t Naomi

+0

再次感謝@SheldonGriffin!我們還發現「callSuccessFunction」需要用REAL調用函數取代。我們使用這一個在成功提交後將瀏覽器重定向到感謝頁面。 成功:函數(){ \t \t \t \t \t window.location.href =「http://www.seednouveau.com/ThankYou。HTML「; \t \t \t \t}, \t \t \t \t失敗:函數(){} 刪除整個線一起還提供了正當的AJAX消息中發送,最初旨在在原始代碼中的警報。 再次感謝您! – Naomi

+0

對不起。我是StackOverflow的新手。不知道如何正確格式化這些消息! – Naomi