How do I Modify a json File Using Javascript:

Asked

Viewed 318 times

1

I have an ajenda already removed the data from it with jquery now I want to create a way to insert data into that agenda Obs:html file is hosted along with the.json agenda

agenda json.:

[
 {
  "nome":"Joao",
  "tel":"998765432"
 },
 {
  "nome":"pedro",
  "tel":"991234567"
 }
]

javascript:

<script src="jquery-3.2.1.min.js"></script>
<script>
function jjson(url, callback){
   $.getJSON( url, callback);
}
jjson("https://robotoscar.000webhostapp.com/agenda.json", 
    function(JSON){
        ajenda=JSON;
        for(i=0;i<agenda.length;i++){
        document.getElementById("lista").InnerHTML+="<li>Nome:"+agenda[i].nome+"<br>Tel:"+agenda[i].tel+"</li>";
    }
});
</script>
<body>
<h1>Contatos:</h1><br>
 <div id="lista"></div>
</body>
  • There is no way, only using a language that runs in the back end, like php for example.

  • 1

    @Andrefigueiredo would be better this https://answall.com/questions/7974/scrindo-e-lendo-arquivo-via-javascript

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.