Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-07-2012, 08:54 PM   PM User | #1
fishbaitfood
New Coder

 
Join Date: Nov 2011
Posts: 30
Thanks: 5
Thanked 0 Times in 0 Posts
fishbaitfood is an unknown quantity at this point
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!
fishbaitfood is offline   Reply With Quote
Old 03-08-2012, 04:01 PM   PM User | #2
Rowsdower!
Senior Coder

 
Rowsdower!'s Avatar
 
Join Date: Oct 2008
Location: Some say it's everything.
Posts: 2,007
Thanks: 5
Thanked 395 Times in 388 Posts
Rowsdower! has a spectacular aura aboutRowsdower! has a spectacular aura aboutRowsdower! has a spectacular aura about
Quote:
Originally Posted by fishbaitfood View Post
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.
__________________
The object of opening the mind, as of opening the mouth, is to shut it again on something solid. –G.K. Chesterton
See Mediocrity in its Infancy
It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
Seek and you shall find... basically:
validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting
Rowsdower! is offline   Reply With Quote
Old 03-09-2012, 01:45 AM   PM User | #3
rnd me
Senior Coder

 
rnd me's Avatar
 
Join Date: Jun 2007
Location: Urbana
Posts: 3,469
Thanks: 9
Thanked 466 Times in 450 Posts
rnd me is a jewel in the roughrnd me is a jewel in the roughrnd me is a jewel in the rough
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.
__________________
my site (updated 5/13)
STATS (2013/5) HTML5:90.2% MOB:14% IE7:0.5% IE8:8.6% IE9:9.8% IE10:10%
rnd me is offline   Reply With Quote
Old 03-13-2012, 09:29 PM   PM User | #4
fishbaitfood
New Coder

 
Join Date: Nov 2011
Posts: 30
Thanks: 5
Thanked 0 Times in 0 Posts
fishbaitfood is an unknown quantity at this point
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!
fishbaitfood is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:07 AM.


Advertisement
Log in to turn off these ads.