refreshing...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

refreshing...

Post by Illusionist »

OK, i've read up on cron jobs and scheduling tasks and stuff, but none of these seem like they can do what i want. All i want is for a page to refresh only when a new comment is added... Instead of refreshing every 2 seconds, i'd like for it to refresh only when a new comment is added... Can this be done?
User avatar
Dr Evil
Forum Contributor
Posts: 184
Joined: Wed Jan 14, 2004 9:56 am
Location: Switzerland

Post by Dr Evil »

Someone correct me if I'm wrong, but I would say no.
The only way you can make the page refresh when something happens on the server is using push technology.

For this you would need a Java applet running to check the server
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

Hmm, ya, you'd need Javascript to do this. An ugly way to do it while being invisible to the user is to open up a new window with Javascript. In that window, have some PHP code that checks the DB. If a new comment is added, reload the parent (main) window, which will then go and get the new info. This will, of course, require a second window to be open, but you could put it behind the main window, so as to be invisible, and use yet more Javascript to close down the child window when the parent closes.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

Php isn't the best choice for chat but it can be done. I vaguely remember a technique for "silent" refreshing using frames, CSS and possibly js. Something like refreshing an (invisible) frame and then using js to copy the new text into the chat area.

Or something. No links - google should track it down.
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

LOL, i think ill try the Java applet way, and i fi can't get it to work that way i'll try to look up some information on what you were saying McGruff. Pickle - no... i dont think thats way i'd ever want to go! thanks though
Post Reply