View Full Version : How can i get the message dynamically?

05-08-2006, 09:07 AM
In an application, I want to get the message dynamicly.

For example:when a system manager add a message to a user, how can that user get this message immediately?

Now, I can just get that message when refreshing that page, but I want to get it dynamicaly, how can I do that? can anyone help me ? Thank you!!!

05-08-2006, 09:13 AM
This is fairly complex.

First, you can't store the data (or send, really) without server side scripting, like php (or asp) or cgi, etc.
You could maybe use java (etc) applets, but that's more complex.

Once you have the data stored (and maybe you do already), you can retrieve it.

What you are referring to sounds a lot like AJAX. The basic idea of AJAX is accessing a php (or other) page without refreshing, by basically refreshing through javascript in the background.

There is a script here on dynamic drive for exactly that. Look up "basic AJAX routine".

What you are asking is even more complex.

You want to have two users communicate.

It's not impossible, but will be harder.

The main thing to figure out is how you will store the message then how the page will check if that user (how are they logged in?) has any new messages.

This can be done with AJAX, but it's also a bit more complex.

More info about AJAX should be helpful. Aside from that, it will be hard to figure this out without more details.

05-09-2006, 05:55 AM
Thank you for that!

Now, I have a solution for that problem.

I write a javascript function in the page which will be visited by users, that function will check whether that user has any news from database in a distance, for example:30 seconds, if there were any news for that user, it will show those news in the page.

thank you ! djr33

05-09-2006, 07:09 AM
That sounds just fine.

The problem, again, is that:
1. They will have to be AT the page.. it won't just pop up from their desktop. Depending on how active your users are, this can be limiting. (tried things similar to this myself and seen this.)
2. You need to have them logged in. How are you doing this? Javascript isn't too secure with logins. Are you using php for checking or something?

But... ignoring those two issues, sounds like it will work great.