I would like to change values of a json file by using javascript. Here is the json file :
{
"login": "",
"password": "",
"ip": "",
"port": "",
"protocol": ""
}
And here is what I've tried to change the values :
$('#save').click(function () {
var login = $("#login").val();
var password = $("#password").val();
var ip = $("#ip").val();
var port = $("#port").val();
var protocol = $("#protocol").val();
var jurl = "setting.json";
$.getJSON(jurl,
{
format: "json"
},
function (data) {
data.login = login;
data.password = password;
data.ip = ip;
data.port = port;
data.protocol = protocol;
});
});
I use <input type="text"> to define the values
HTTPPUTmethod is designed for?PUTthat way. It's really bad for security to accept any file.