I am trying to add data to *.JSON file, that has only this text: {}. Ajax returns "success", but the file remains as before. Also I have noticed if the JSON file is empty, nothing happens at all. Please, help me to find a solution. I don't get where the trouble is. Maybe, you know what else can be the reason of the problem. Thank you.
The code of the ajax:
$.ajax({
type: "POST",
url: "data/test.json",
data: JSON.stringify({ "userName": "1", "password" : "1" }),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data){alert("success");},
fail: function(errMsg) {alert("fail");
}
});