I have a basic form with some input fields. I want to save form data to json file when submitting form. The format of the stored data in the json file should be like this.
[ {"title":"some text","description":"some text","info":"some text","username":"some name"}, {"title":"some text","description":"some text","info":"some text","username":"some name"}, {"title":"some text","description":"some text","info":"some text","username":"some name"} ]
I tried to do this using this code, but no data was saved in my "story.json file"
$('form').submit(function() { $.ajax({ type: 'POST', dataType: 'json', url: 'story.json', data: $(this).serialize(), success: function(data) { alert(data.message); }, failure: function (data) { alert('Please try again'); } }); });
I want to save the data of this form in a local file. Please help me find the right way to do this. Thanks
source share