I know there are lots of other similar questions all over, but I couldn't yet write the data from an object (a spreadsheet) to a JSON file.
This is my JS:
function (){
var spread = $("#ss").wijspread("spread");
var activeSheet = spread.getActiveSheet();
var dados = JSON.stringify(spread.toJSON());
activeSheet.bind($.wijmo.wijspread.Events.EditChange, function (sender, args) {
console.log(dados);
$.ajax({
url: 'script.php',
data: dados,
dataType: "json",
type: "POST"
});
});
}
The data is sent to the console whenever there are changes in the spreadsheet, the file is created in the server but it is empty.
This is script.php
$myFile = "/file.json";
$fh = fopen($myFile, 'w') or die("impossible to open file");
$stringData = $_POST['data'];
$stringData=json_encode($stringData);
fwrite($fh, $stringData);
fclose($fh);
json_encode()the already-encoded data?