-3
我有兴趣从我的联系表单中检索用户的姓名和电子邮件,并使用它显示如下所示:“感谢您的留言$ name,我们将回复至以下邮箱:$电子邮件”我想更改中,.done功能如何从PHP中检索信息并在javascript中使用它
这里是JavaScript:
$.ajax({
type: 'POST',
url: "sendemail.php",
data: {
Name: $form.find("input[name='name']").val(),
Subject: $form.find("input[name='subject']").val(),
Email: $form.find("input[name='email']").val(),
message: $form.find("textarea[name=message]").val(),
},
beforeSend: function() {
form.append(form_status.html('<p style="font-weight:bold;color:white;"><i class="fa fa-spinner w3-text-white w3-spin" style="font-size:50px"></i> Email is sending...</p>').fadeIn());
}
}).done(function (data) {
//here is the function i want to insert the information
form_status.html('<p style="color:white;" class="text-success w3-animate-fading"><i class="fa fa-check fa-2x" aria-hidden ="true"></i>\n\
Message sent. Thank you for contacting us phpName, we will reply to the following email: phpEmail <i class="fa fa-smile-o fa-2x" aria-hidden="true"></i> </p>')
.delay(7000).fadeOut();
});
请问你'sendemail.php'反应?页面输出什么? –
请分享您的'sendemail.php' –
您无需从PHP获取值。你已经拥有了你的JS。例如'$ form.find( “输入[名称= '电子邮件']”)。VAL()'。只要使用它。 – Mike