How to code a server-initiated notification window

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
cormanaz
Forum Newbie
Posts: 3
Joined: Fri Jun 27, 2008 9:33 am

How to code a server-initiated notification window

Post by cormanaz »

Hello all. I am trying to figure out how I can get php to create a notification window. Specifically, I have news items listed on a page and I want users to be able to click a link that is part of the item to flag it for others (i.e. sort of a social bookmarking function). When such a link is clicked, I will need to either notify them that their action has succeeded or that they have already flagged the item. I would like this to happen with a popup or similar control, as I don't want to navigate users away from the page.

I know I could use php to insert javascript to do popups, but that is client side. The checking for success or an existing flag will need to operate on the server side, so the server will have to open the window. Is there some way to use php to accomplish what I'm describing here?

TIA

Steve
nowaydown1
Forum Contributor
Posts: 169
Joined: Sun Apr 27, 2008 1:22 am

Re: How to code a server-initiated notification window

Post by nowaydown1 »

Greetings Steve,

Welcome to the forum. At some point down the line, you will have to fall back on javascript to get your popup window thing going. If you want to have your success / existing flag check done by the server, you could use AJAX to send a request to your PHP backend, have javascript parse the result, and open a popup window accordingly. So in that circumstance, your server side will make the open / don't open decision, and the client side is responsible for dealing with how to open the window or notify the user, etc.

If you haven't worked with AJAX before, there's tons of stuff about it online. Just google around a bit.
Post Reply