I am sending this json object to the server :
[
{
"row_id": 1,
"status": "Anmeldung",
"ma_name": "AA",
"datum": "/",
"fa1": "testname1",
"fa2": "testname2",
"limit": "10.000",
"gruppe_kredit": "/",
"omv_kdnr": "8124213",
"sap_kdnr": "/",
"fos": "/",
"hga_kdnr": "/"
},
{
"row_id": 3,
"status": "Anmeldung",
"ma_name": "AA",
"datum": "/",
"fa1": "ame1",
"fa2": "name2",
"limit": "12.000",
"gruppe_kredit": "/",
"omv_kdnr": "81515616",
"sap_kdnr": "/",
"fos": "/",
"hga_kdnr": "/"
},
{
"row_id": 2,
"status": "Kunde",
"ma_name": "AA",
"datum": "/",
"fa1": "newname1",
"fa2": "newname2",
"limit": "15.323",
"gruppe_kredit": "/",
"omv_kdnr": "81515616",
"sap_kdnr": "/",
"fos": "/",
"hga_kdnr": "/"
}
]
I am sending it with jquery AJAX as following:
var save = document.getElementById('save-table');
save.addEventListener("click", function(e){
e.preventDefault();
getAllContents();
console.log(updateObj);
updateObj = JSON.stringify(updateObj);
console.log(updateObj);
$.ajax({
url: "http://192.168.54.11/tabellen/logic/omv.php",
type: "POST",
data: updateObj,
success: function(response){
console.log("Success: ", response);
},
error: function(response){
console.log("Error: ", response);
}
});
});
My PHP Code only consists of this :
<?php
echo "<pre>";
print_r(json_decode($_POST));
echo "</pre>";
die;
?>
When I log the response within my ajax call i just receive <pre></pre>
back without any POST data. When I inspect the Network Tab Headers I can see the missing data in the Form Data part on the very bottom.
Any ideas?
Add to ajax contentType: "application/json; charset=utf-8"