Answer the question
In order to leave comments, you need to log in
How to save text in textarea on website when changing?
I want to transfer text from my phone to a computer, and I needed to make sure that with any change in the text in the textarea on the site, the text is saved and is not reset when the site is updated. I've searched the internet and still can't figure it out. Please explain how to do it?
Answer the question
In order to leave comments, you need to log in
1. When adding text, it is necessary to execute an AJAX request that will transfer the field data to the processing script on the server. As an option, you can catch the event of either the loss of focus by the element, or the keystroke event, there is also a plugin for js, in which all possible events for entering text into the field are already implemented - you can use it.
2. On the server (let's say you have a PHP server part), the script accepts an incoming request and processes the received data by validating and writing it to the database.
3. When the page is loaded, the field is filled from the data received in the database.
4. If you want to synchronize data changes without updating pages on the site and phone, you can look aside (WebSocket is a communication protocol over a TCP connection designed to exchange messages between a browser and a web server in real time), or put timer on the page and constantly monitor via AJAX database. In case of a change, pull the data into the field.
You can save to the database and load from there, but this is done if there is registration and login on the site
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question