PHP - Ajax Chat using logfile, without reload?
I have this PHP-jQuery-Ajax chat application, which uses PHP to open and write to a logfile and with jQuery and Ajax displaying and posting the messages.
However, when loading the logfile with Ajax, there's a setInterval attached to reload it every 2.5 seconds or so.
Now my problem is that when selecting content of the chatlog, the selection gets removed obviously, because of the reloading.
How can I make the messages kind of permanent on the page, for selecting posted links and such.
This must be possible some way, right, because chatmodules like Facebook's one also achieves this.
Can someone please inform or instruct me on how to do this?
you can break the incoming data into chunks and render them atomically. this lets you always use append, which means you don't need to replace ui. If you mean a textarea, you'll have to manually memorize the .scrollTop, .selectionStart, and .selectionEnd properties, and re-set those to the old values after you change the .value.
Solved it to only reload the content when a message is sent.
But your append method, rnd me, is something to definately consider in the future! Thanks.
And sorry Rowsdower!
|All times are GMT +1. The time now is 09:24 PM.|
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.