I created a UI to read, write and update a config file using HTML but I am not able to save new JSON object to my existing config file.
So I need to post JSON object from HTML file to nodejs server
JAVASCRIPT
var testJson = { name: "mufashid" }
$.ajax({
url: 'http://localhost:3000/test/config',
type: 'POST',
dataType: 'json',
data: { o: JSON.stringify(testJson ) }, // bags collection value what your goging to send to server
// crossDomain: true,
success: function (data) {
alert('Success!')
},
error: function (jqXHR, textStatus, err) {
//show error message
alert('text status ' + textStatus + ', err ' + err)
}
});
nodejs
app.post('/test/config', function (req, res) {
// console.log(res);
console.log(req)
})
Need to update the config file with the new value when pressed the save button.