Javascript Sweetalert2要在电子邮件上显示的文本区域输入
如何接收用户在文本区域内的输入?下面是我更详细的意思: 我的JS看起来像这样:Javascript Sweetalert2要在电子邮件上显示的文本区域输入,javascript,php,ajax,Javascript,Php,Ajax,如何接收用户在文本区域内的输入?下面是我更详细的意思: 我的JS看起来像这样: $('#sad').on('click', function() { const sad = $('#sad').val(); const { value: text } = Swal.fire({ title:'<strong>Lass uns mehr erfahren</strong>', input: 'textarea'
$('#sad').on('click', function() {
const sad = $('#sad').val();
const { value: text } = Swal.fire({
title:'<strong>Lass uns mehr erfahren</strong>',
input: 'textarea'
}).then(function() {
$.ajax({
type: "POST",
url: "feedback.php",//===PHP file name and directory====
data:{sad: sad},
success:function(data){
console.log(data);
//Success Message == 'Title', 'Message body', Last one leave as it is
Swal.fire({
icon: 'success',
title: "Danke!",
showConfirmButton: false,
timer: 3000
});
},
error:function(data){
//Error Message == 'Title', 'Message body', Last one leave as it is
Swal.fire({
icon: 'error',
title: 'Oops...',
text: 'Something went wrong!'
})
}
});
if (text) {
$.ajax({
type: "POST",
url: "feedback.php",
data: {'text': text}
})
}
})
})
我收到$txt部分,但不是每封电子邮件的用户输入:
“哦,不,你得到了一个新的‘Sad’评论’在下面的代码中,我在
函数(result)
中传递了textarea的值,然后我使用result.value
访问textarea的值并将其传递给ajax调用
演示代码:
$('sad')。在('click',function()上{
const sad=$('#sad').val();
常数{
值:文本
}=游泳池火灾({
标题:“Lass uns mehr erfahren”,
输入:“文本区域”
}).然后(函数(结果){
//检查用户是否在文本框中键入了内容
if(result.value){
//控制台打印
console.log(result.value)
$.ajax({
类型:“POST”,
url:“feedback.php”,//==php文件名和目录====
数据:{
悲伤:悲伤,
values:result.value//回答了你的问题吗?一点也不。他问了关于添加textarea的问题。我想弄明白的是如何将用户在textarea中输入的数据发送到我的php,然后显示在我的电子邮件中。正如你所看到的,我已经有了一个输入:“textarea”
它可以工作!!!!但是为什么我会得到true
回复我的电子邮件?我是否应该更改'result.text'以接收文本输出?哦,顺便说一句,非常感谢@Swati的帮助。
$sad = $_POST['sad'];
$text = $_POST['text'];
elseif(isset( $_POST['sad'] )) {
$EmailFrom = "xxxxxxxx@gmail.com";
$Subject = "New Feedback";
$mailTo = "info@xxxxxxxx.me";
$txt = "Oh no, you got a new 'Sad' review".$text;
$headers = 'From: ' .$EmailFrom. "\r\n";
mail($mailTo, $Subject, $txt, $headers);
header("Location: https://xxxxxxxx.me/?mailsend");
}