Is it possible to edit a JSON file using javaScript?
I’m trying to read my JSON file in like so:
jQuery.getJSON('http://test.javascript.com/jscrud/json/test.json')
.done(function(data) {
element.html("<form> ");
$.each(data,function(k, v) {
element.append(k+": <input type='test' name="+k+" value="+v+" /><br />");
});
element.append("</form>");
})
.fail(function(data) {
alert("did not read file");
});
From this, a form is created and populated. I want to be able to edit the form, click “save” and have the JSON file to be updated with meta data saying what was edited.
Is this possible or am I wasting my time?
You need to write a server-side script that receives your modified JSON using AJAX and saves it somewhere on the server.