ProblemHelpPlease Posted August 25, 2011 Share Posted August 25, 2011 I am looking at adding the ability to force all users viewing a page to receive an update to the page (a new text entry) at the moment that it is added by another user, something similar to they way chat rooms work.The active part that needs to show the live updates will be text in a textarea field. Currently any text typed into the textarea is automatically inserted into a database with the use of javascripts onkeyup() and some ajax. Other users are required to refresh there page to see the latest updates in the textbox and this is the bit that I would like to avoid.I haven't ever needed to do this before so don't have knowledge of what would be the best way to go about this. Link to comment Share on other sites More sharing options...
justsomeguy Posted August 25, 2011 Share Posted August 25, 2011 There needs to be something that checks for updates periodically and updates the page if there is anything new. Link to comment Share on other sites More sharing options...
ProblemHelpPlease Posted August 25, 2011 Author Share Posted August 25, 2011 The issue I have is how to update multiple textarea boxes on the same page. They are created dynamically so numbers can be anywhere from 1 to 100 boxes, each linked to a different row in the database. If it was just updating 1 box then I could achieve this with some JS but with so many boxes I can see it struggling to handle the volume. Any ideas how to get round this, I can't reduce the number of boxes. Link to comment Share on other sites More sharing options...
justsomeguy Posted August 25, 2011 Share Posted August 25, 2011 You still only need one request, regardless of how many things there are on the page to update. The response just needs to include an update for each thing that needs to be updated. Link to comment Share on other sites More sharing options...
ProblemHelpPlease Posted September 6, 2011 Author Share Posted September 6, 2011 I tested the update using 100 boxes which is about the most I will see on the page and the javascript was slowing the page down slighty which was a problem as the page cant afford for this to happen.I made a different solution using a simple mouseover on each textarea that fetches the latest content for the textarea from the mysql server and redisplays it in the textarea. As a user puts there cursor in the textarea to type a message it activates the update and redisplays the message before they can type over it. As it only affects each textarea individually it massively reduces the update time. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.