I wont create a JSON file and save this with a php script. I got this error message (Firefox)
NS_ERROR_XPC_JSOBJECT_HAS_NO_FUNCTION_NAMED: JavaScript component does not have a method named: "available"'JavaScript component does not have a method named: "available"' when calling method: [nsIInputStream::available]
When i use Chrome I didn't get the error message but it doesn't work too.
JavaScript:
var jsonString = '{ "foo": 1, "bar": { "baz" : 1 } }';
var data = JSON.parse( jsonString );
var xhr = new XMLHttpRequest();
xhr.open('POST', './php/upload.php', true);
xhr.send(data);
PHP:
$dateiname = "test12345.json";
if (isset($_POST) && count($_GET)==0) {
$jsonObj = $_POST;
$fh = fopen($dateiname, 'w');
$input = json_encode($jsonObj);
fwrite($fh, $input);
fclose($fh);
}