How to encode saved comments?

I tried to code, not exactly comments, but just something simple. The user enters something and he remains on the website. For example, if I typed “hello” as soon as I sent a comment, if I refresh the page, I will still see my comment. It would also be useful if there was a field in which a person could enter his name, and their name would remain too. I encoded this, but I can't figure out if there were any comments left.

h2 { font-family:arial; } form { display: inline-block; border: 1px solid #23008B; } #button{ display: inline-block; height:20px; width:70px; background-color:#4000FF; font-family:arial; font-weight:none; color:#ffffff; border-radius: 5px; text-align:center; margin-top:2px; padding-top: 2px; } .list { font-family:garamond; color:#cc0000; } 
 <!DOCTYPE html> <html> <head> <title>Insert Comments</title> </head> <body> <h2>To Do</h2> <form name="checkListForm"> <input type="text" name="checkListItem"/> </form> <div id="button">Add!</div> <br/> <div class="list"></div> </body> </html> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> <script> $(document).ready(function() { $('#button').click(function() { var toAdd = $('input[name=checkListItem]').val(); $(".list").append("<div class = 'item'>" + toAdd + "</div>") }); }); </script> 
I just wanted to know what I am missing and if there is anything in HTML or jQuery to solve this problem. Thanks.
+5
source share
1 answer

You can save your data using the localStorage browser . >

To share the same data among several users, you can use the client-server architecture, where any browser can act as a client and another separate program as a server, the server will be responsible for maintaining, maintaining and updating data like this:

  • The client requests a web page from the server.

  • The server fills the page with all user comments in its repository (data file, file, etc.) and sends it to the client.

  • If the user adds a comment, the client sends a comment to the server.
  • The server adds a comment to its repository and notifies all connected clients of the newly added message.

You can start here .

0
source

All Articles