Save data to a file and retrieve it with jquery

1

I want to simulate a blog article and save a comment purely by Javascript so I have 3 files to accomplish this task:

$("#enviar-comentario").click(function(){
	var nome = $("#nome").val();
	var mensagem = $("#mensagem").val();

	var msg = {
		nome: nome,
		mensagem: mensagem
	}
	var dados = {
		comentario: msg
	}
	$.post("http://127.0.0.1/edsa-direct/blog-inovacoes/js/comentarios", dados, function(){
		console.log("Enviei os dados");
	}).fail(function(){
		console.log("Não deu certo");
	});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script><divclass="comentar col m8 s12 indigo lighten-5">
				<h5 class="center titulo-comentarios">Adicionar um comentário</h5>

				<div class="input-field col s12">
		          <input id="nome" type="text" class="validate">
		          <label for="nome">Nome</label>
		        </div>

				<div class="input-field col s12">
				  	<textarea id="mensagem" class="materialize-textarea" maxlength="150"></textarea>
				    <label for="mensagem">Mensagem</label>
				</div>

				<div class="center">
					<a class="waves-effect waves-light btn" id="enviar-comentario">Comentar</a>
				</div>
</div>

And then, as seen in the js part, I send to a file called comentarios which is a simply an empty file. The request responds successfully, but when updating the data was not saved there!

What can I do to save the data in this file?

    
asked by anonymous 09.11.2017 / 20:18

0 answers