如果一直在尝试一段时间,并且无法在没有帮助的情况下使其工作。不能发送带有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