Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/236.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
Php 复选框值通过ajax传递_Php_Html_Ajax - Fatal编程技术网

Php 复选框值通过ajax传递

Php 复选框值通过ajax传递,php,html,ajax,Php,Html,Ajax,我有一个带有复选框的表单。我使用$.ajax()在php端发送值 <input type="checkbox" id="1" name="order[]" value="cake"> cake <input type="checkbox" id="2" name="order[]" value="cupcake">cupcakes <input type="checkbox" id="3" name="order[]" value="cake

我有一个带有复选框的表单。我使用$.ajax()在php端发送值

    <input type="checkbox" id="1" name="order[]" value="cake"> cake
    <input type="checkbox" id="2" name="order[]" value="cupcake">cupcakes
    <input type="checkbox" id="3" name="order[]" value="cakepops">cakepops
    <input type="checkbox" id="4" name="order[]" value="whoopee pies">whoopee pies
    <input type="checkbox" id="3" name="order[]" value="cookies">cookies
蛋糕
纸杯蛋糕
结块
大喊派
饼干
我用来在服务器上发送数据的代码是

               var m_data = new FormData();
                m_data.append( 'user_name', $('input[name=name]').val());
                m_data.append( 'user_email', $('input[name=email]').val());
                m_data.append( 'user_order', $('input[name="order"]:checked').val());
 $.ajax({
                    url: 'get_mail.php',
                    data: m_data,
                    processData: false,
                    contentType: false,
                    type: 'POST',
                    dataType:'json',
                    success: 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>';
                        }
                        $("#contact_form #contact_results").hide().html(output).slideDown();
                    }
                });
var m_data=new FormData();
m_data.append('user_name',$('input[name=name]').val());
m_data.append('user_email',$('input[name=email]').val());
m_data.append('user_order',$('input[name=“order”]:checked').val();
$.ajax({
url:'get_mail.php',
数据:m_数据,
processData:false,
contentType:false,
键入:“POST”,
数据类型:'json',
成功:功能(响应){
//从服务器加载json数据并输出消息
如果(response.type=='error'){
输出=''+响应。文本+'';
}否则{
输出=''+响应。文本+'';
}
$(“#联系形式#联系结果”).hide().html(输出).slideDown();
}
});

我被困在这里,任何人都能帮助我吗?

你能详细说明一下你被困在哪里,你无法获得复选框值,或者你无法通过ajax发送它吗?在表单提交后,你得到了什么参数?我无法获得复选框值,因为我希望它们通过使用php的电子邮件接收。