CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   Ajax and Design (http://www.codingforums.com/forumdisplay.php?f=55)
-   -   PHP - Ajax Chat using logfile, without reload? (http://www.codingforums.com/showthread.php?t=253556)

fishbaitfood 03-07-2012 08:54 PM

PHP - Ajax Chat using logfile, without reload?
 
Hello all,

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?

Thanks!

Rowsdower! 03-08-2012 04:01 PM

Quote:

Originally Posted by fishbaitfood (Post 1201774)
Hello all,

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?

Thanks!

A link to your test page would do wonders for us. :D

rnd me 03-09-2012 01:45 AM

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.

fishbaitfood 03-13-2012 09:29 PM

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 06:57 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.