Hello ,
I have requirement where i have update json static file values from form values entered by user once the form is submitted .
tried below script but i suspect its not reading json file to update
<script>
function showMessage(myform){
// Read the JSON file
const fs = require('fs');
let jsonData = JSON.parse(fs.readFileSync("test.json"));
// Add or edit data
jsonData.Test1.type = AJS.$(myform).find('#i_mydropdown').val();
// Write the JSON file
fs.writeFileSync("test.json", JSON.stringify(jsonData))
}
</script>
Are you trying to update a file in your local computer by executing a JavaScript in a browser?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.