TAGS :Viewed: 3 - Published at: a few seconds ago

[ jQuery serializeArray doesn't work in server side ]

I have a forms with about 40 fields in my page, so I decided to use jQuery serializeArray() method to retrieve this values.
So, I wrote this lines in my **jQuery** code:

            $(document).on('click', '#send_bosch_package_detail', function() {
                var data = $('#frmbosch').serializeArray() ; 
                $.ajax({
                    type:'POST',
                    url:"../proccessors/package_pro.php",
                    data: data,
                    success: function(result) {
                        $('#right').html(result);
                    }
                });
            });

and in my PHP code:
I'm using PDO for DataBase stuff and this lines are part of my PHP page

$exe = $prepare->execute( array( 
':model'=>$_POST['model'], 
':special_name'=>$_POST['special_name'], 
':output'=>$_POST['output'],
':roi'=>$_POST['roi'],
':power_cons_noload'=>$_POST['power_cons_noload'],
':max_output_power'=>$_POST['max_output_power'],
':initial_press_expand_source'=>$_POST['initial_press_expand_source'],
':net_capacity_expand_source'=>$_POST['net_capacity_expand_source'],
':heating_power_temperature'=>$_POST['heating_power_temperature'],
':water_temperature'=>$_POST['water_temperature'],
':working_pressure_heat_circuit'=>$_POST['working_pressure_heat_circuit'],
':working_pressure_hot_water_circuit'=>$_POST['working_pressure_hot_water_circuit'],
':minimum_water_flow'=>$_POST['minimum_water_flow'],
':maximum_hot_water_50deg'=>$_POST['maximum_hot_water_50deg'],
':maximum_hot_water_30deg'=>$_POST['maximum_hot_water_30deg'],
':pump_power'=>$_POST['pump_power'],
':pump_frequency'=>$_POST['pump_frequency'],
':pump_power_consump'=>$_POST['pump_power_consump'],
':noise_in_maximum_power'=>$_POST['noise_in_maximum_power'],
':height'=>$_POST['height'],
':width'=>$_POST['width'],
':depth'=>$_POST['depth'],
':weight'=>$_POST['weight'],
':gas_consump_max'=>$_POST['gas_consump_max'],
':other_comments'=>$_POST['other_comments'],
':price'=>$_POST['price'],
':available'=>$_POST['available'],
':guaranty'=>$_POST['guaranty'],
':guaranty_name'=>$_POST['guaranty_name'],
':store_date'=>$date,
':delivery_time'=>$_POST['delivery_time']
) );

Would you tell me which part of my Code is wrong??
When I try var_dump($_POST) in my PHP code, every thing is OK, but when I try to write the values to my DB, I see undefined index in $_POST error for all of mu fields!!!!
error<code>enter code here</code>
Either when I dump the $exe with var_dump, the program tell me $_POST is empty... enter image description here

Thanks in advance

Answer 1


As much as I know, there is not something wrong in your code's logic,
I can't leave comment for you because of my reputation.
But, as an experience, when you use some of characters like -, /, . or etc in your DB field name, you have to separate the field names by ' or ( ` ).
for example:
PHP:

'INSERT INTO yourDB( `field1`, `field2`, `field3`, ... )'

or

"INSERT INTO yourDB ( 'field1', 'field2', 'field3', ... )"

I think the problem should be in your PHP code