refreshing...
Moderator: General Moderators
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
refreshing...
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?
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
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
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.
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.
Or something. No links - google should track it down.
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm