I am a newbie to javascript
I would like add a new object to my json file likejson.json
Is it possible to insert new object to json file using javascript or jquery?? I try the following code, but not work
$( document ).ready(function() {
$.ajax({
method: "POST",
url: "ht tps:// mysite.com/json.json",
dataType: "json",
contentType: "application/json",
data: JSON.stringify({ Name: "John", latitude: "111", longitude: "222",status:"R" }),
})
.done(function( msg ) {
alert( "Done: " + msg );
})
.fail(function( jqXHR, textStatus ) {
alert( "Request failed: " + textStatus );
});
});
but I using postman is very easy to add new object.
Any idea how to use javascript or jquery ajax to insert new object to json file??
Thank you vey much, have a nice day