繁体   English   中英

无法将数据发布到php,看不清为什么

[英]Can't post data to php, Can't see why

我有一些数据从表单发送到php脚本以发送电子邮件,它来自模板,但我认为这是错误的。 我已经隔离了应归咎于代码的部分。 特定的代码似乎是{'userName':user_name,'userEmail':user_email,'userMessage':user_message}部分(您可以在第三行的注释中看到我尝试摆弄的地方) 。 任何帮助,将不胜感激!

 if(proceed) 
    {
        //data to be sent to server
        //post_data = {'userName':user_name, 'userEmail':user_email, 'userMessage':user_message};
        //Ajax post data to server
        $.post('contact_me.php',  {'userName':user_name, 'userEmail':user_email, 'userMessage':user_message}, function(response){  

            //load json data from server and output message     
            if(response.type == 'error')
            {
                output = '<div class="error">'+response.text+'</div>';
            }else{
                output = '<div class="success">'+response.text+'</div>';

                //reset values in all input fields
                $('#contact_form input').val(''); 
                $('#contact_form textarea').val(''); 
            }

            $("#result").hide().html(output).slideDown();
        }, 'json');

    }

UserName和其他变量不需要单引号。 只是{userName:user_name}

依此类推

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM