I'm trying to write a json file based upon a filled in Form
So I used an external Library for jquery that converts the Form into legitimate JSON. When I console.log that output I do get a valid json data returned.
So whenever I pass the data into a php using $.ajax and write the content to a file the PHP saves the file but the inside it just says "NULL"
here is my AJAX:
$(document).ready(function() {
var json = $("#user-form").serializeJSON();
$.ajax({
url: "writejson.php",
type: "POST",
data: json,
processData: false,
contentType: 'application/json'
});
})
And here is my PHP:
<?php
$myFile = "kiosk.json";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh,var_export($_POST['data'], true));
fclose($fh);
?>
and here is what the outputted file says:
NULL
I tried looking it up here first and tried numerous options but none of them seem to save the correct data. really strange.
Thanks in advance!