Well I followed this question, but cannot send array to php it returns me always empty:
JS:
values = []; values['mpsRegnomer'] = $('#mpsRegnomer').val(); values['mpsMarka'] = $('#mpsMarka').val(); values['mpsMarkaOther'] = $('#mpsMarkaOther').val(); values['engineType'] = $('#engineType').val(); values['seatNumberInput'] = $('#seatNumberInput').val(); values['carColor'] = $('#carColor').val(); values['mpsChassiNum'] = $('#mpsChassiNum').val(); values['mpsModel'] = $('#mpsModel').val(); values['mpsModelOther'] = $('#mpsModelOther').val(); values['mpsManufactureDate'] = $('#mpsManufactureDate').val(); values['mpsfor'] = $('#mpsfor').val(); values['VehicleType'] = $('#VehicleType').val(); values['dvigatelInput'] = $('#dvigatelInput').val(); values['engineMaxPower'] = $('#engineMaxPower').val(); values['is_automatic'] = $('#is_automatic').val(); console.log(values);$.ajax({ type: 'POST', url: 'assets/clients/services/saveDataMPS.php', async: false, dataType: "JSON", data: {"values": JSON.stringify(values)}, success:function(response){ alert(1); } });
console.log(values) show me that array is OK.
PHP code:
<?phpvar_dump(json_decode($_POST[“values”])); exit;
It returns me always empty, also tried only with var_dump($_POST); same result… Where am I wrong?
Result from console.log(values):
#javascript #php #ajax #jquery