Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/365.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Sweetalert2要在电子邮件上显示的文本区域输入_Javascript_Php_Ajax - Fatal编程技术网

Javascript Sweetalert2要在电子邮件上显示的文本区域输入

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'

如何接收用户在文本区域内的输入?下面是我更详细的意思:

我的JS看起来像这样:

$('#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");
                    }