Shoutbox: Auto-Refresh Design

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
blacksnday
Forum Contributor
Posts: 252
Joined: Sat Jul 30, 2005 6:11 am
Location: bfe Ohio :(

Shoutbox: Auto-Refresh Design

Post by blacksnday »

Im a new scripter to php or any code, and have a question
about how many people design shoutboxs to 'auto-refresh'.

I have been running websites for over 3 years now, and one thing
I have noticed about how shoutboxes are coded to refresh upon new post
is by using cookies or javascript or even meta-type codes.

I just created a shoutbox for my current coding project, and
have not needed any of the above to show the latest shoutbox shout
when a user submits a new shout.

Which brings me to my overall question.

If a new php'r can make a shoutbox that does not require
cookies/javascript/meta/etc..... to auto refresh of new user posts
then why must most shoutboxes use this way and depend on client end
devices to help make it fail?
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

when you submit the form to add a new shout sure, you don't need any of the things you mentioned. However, what about the other 32 new shouts that have come up while you're reading the long article on the page...

you won't see those unless the box is refreshed, you reload the parent page, or you navigate to another page with the box. There still really isn't a 100% clean way of retrieiving data from a server w/o a refresh of some kind but ajax/xmlhttp has made giant steps toward that end.

try googling ajax or xmlhttp or search this forum for posts on the subjects if you're interested in how to retrieve server side data to your client without using any of the methods you mentioned above.
User avatar
blacksnday
Forum Contributor
Posts: 252
Joined: Sat Jul 30, 2005 6:11 am
Location: bfe Ohio :(

Post by blacksnday »

Ahh, ok.. thats makes more sense now why people
would want something to refresh.
However in my case, my shoutbox only shows on the main page
so I really dont need to worry about someone not seeing a new
post before they posted.

If i did need to worry, and since my shoutbox is
being included from an outside file, I could just
use the Meta Refresh so that only the shout box refreshes
and not whole page, couldnt I?
I do plan to read up on ajax/xmlhttp because
that would allow me to create some features
that I have already thought of in my poor head!

thanks alot :)
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

you could use an iframe to have just the shoutbox refresh (that's the way it's most commonly done).

however, without using xmlhttp / ajax you're going to have the annoying clicking sound in IE whenever the iframe refreshes and a possible delay in the page reloading.

edit: after more careful consideration, I guess you could reload the page with JS w/o the annoying clicking sound

something like:

Code: Select all

setTimeout('location.reload();',60000)
Post Reply