I have a TextArea 'TA' in my website where users can edit its text concurrently.
What I have done so far is the following,
- I set a global variable 'content' in the server side to capture/monitor the value of the TA
- A javascript Ajax function 'JU' that stores the value of the TA to the variable 'content' for any change in the TA. In other words, if the user types anything in the TA, the content value gets updated (content=TA.value)via the onkey() function
- A javascript Ajax function 'JR' that reads the variable 'content' every second to update TA using TA.value=content
However, with this approach I'm facing the race condition or similar issues. For instance, if I write quickly in the TA, some of the letters gets removed because the TA reads the variable 'content' to update its value before it stores what I wrote to 'content'
I tried tricks such as resetting the timer of JR for updating TA everytime the user types, however, the issue persists, albeit less. Furthermore, with this approach if a user keeps typing he wouldn't see what other users are writing until later...
Thanks in advance!
PS: I'm using python as the server-side language (bottle framework)