如果一直在嘗試一段時間,並且無法在沒有幫助的情況下使其工作。不能發送帶有ajax的變量到php
我想將聯繫表單中的變量發送到php以便將郵件發送給我。
的JS看起來是這樣的:
$("#submitQuote").live('click',function(){
var shirt_style = "shirt_style="+$(".dropdown[title=shirt_style] .dropdownValue").text();
var shirt_type = "&shirt_type="+$(".dropdown[title=shirt_type] .dropdownValue").text();
var cuffs = "&cuffs="+$(".dropdown[title=cuffs] .dropdownValue").text();
var chestpoket = "&chestpoket="+$(".dropdown[title=chestpoket] .dropdownValue").text();
var collar = "&collar="+$(".dropdown[title=collar] .dropdownValue").text();
var collar_buttons = "&collar_buttons="+$(".dropdown[title=collar_buttons] .dropdownValue").text();
var fastening = "&fastening="+$(".dropdown[title=fastening] .dropdownValue").text();
var cut = "&cut="+escape($(".dropdown[title=cut] .dropdownValue").text());
var Name = "&Name="+escape($("input[name=Name]").val());
var Email = "&Email="+escape($("input[name=Email]").val());
var Phonenumber = "&Phonenumber="+escape($("input[name=Phonenumber]").val());
var Address = "&Address="+escape($("input[name=Address]").val());
var Zipcode = "&Zipcode="+escape($("input[name=Zipcode]").val());
var City_country = "&City_country="+escape($("input[name=City_country]").val());
var Copy = "&Copy="+$(".checkbox[title=Copy]").hasClass("checkboxChecked");
var form_values1 = shirt_style+shirt_type+cuffs+chestpoket+collar+collar_buttons+fastening+cut;
var form_values2 = form_values1+Name+Email+Phonenumber+Address+Zipcode+City_country+Copy;
$.ajax({
type: "POST",
url: "http://www.....com/ajax/mail.php",
data: form_values2,
success: function() {
$('html,body').animate({scrollTop:290},1000);
$("#quoteStepContainer").html('');
$("#quoteStepContainer").html('<img src="http://www...com/img/sent.jpg" width="625" height="160" alt="Thank you" id="thankyouimage" />');
$("#thanksImage").fadeIn(1000);
$("#quoteStepContainer").delay(1000).animate({"height": "190px"},1500);
}
});
return false;
});
我想form_values2被髮送給我,但我不能得到它的工作。
我認爲我的主要問題是,我不確定如何發送的form_values2變種的PHP文件看起來像。
非常簡單的php測試表單不起作用。
<?php
$mail = $_POST['Email'];
$name = $_POST['Name'];
$to = "[email protected]";
$message =" You received a mail from ".$mail;
$message .=" His name is : ".$name;
if(mail($to,$mail,$message)){
echo "mail successful send";
}
else{
echo "there's some errors to send the mail, verify your server options";
}
?>
非常感謝您的幫助。
亞倫
非常感謝你的回覆尼克。但我認爲主要的問題是PHP文件本身。我不明白。你可以幫我嗎? – Aaron 2010-12-15 11:17:23
@Aaron - 我在你的問題中沒有看到任何PHP代碼,你可以添加它嗎? – 2010-12-15 12:11:11
尼克,這是我的主要問題:(我無法編碼一個PHP文件,這將給我發送變量「form_values2」。上面的代碼是正確的,我只是點得到它如何編碼mail.php爲了電子郵件我的變量 – Aaron 2010-12-15 12:13:43