1

I have a situation where an event have to affect several web pages on an event is triggered.

Its like in GMail. I am developing a project based on online stocking trading system for my college. There are asking for a facility where the administrator or the dealer doesn't need to refresh his end of the application to view the new orders placed by the customers at the other end of the application.

As I said its like GMail, wait for the event to happen, listen to it and update the page.

I am good at JavaScript and jQuery that I can do this within a page: event listeners. But how to do this across several pages.

You can also consider another situation: A waiter, a cashier and a cook in a hotel, all have a PDA with them, any of them doesn't have to refresh their instance of web page to update the orders placed.

How can I achieve this? Is this possible? I say I am good at javascript but I have my limits and doubts.

I use jQuery and PHP.

Thanks in advance.

PS: I know how to refresh the page or iFrame for every 5 seconds or so.

Edit 1:

As for additional details, I want to something similar to below that is done in java

synchronised(sync)
{
   sync.wait()
}

The code may not be accurate, this was from my lab experiments. But the concept is similar. Server waits till the client made a move and this is repeated for a lot of time.

Edit 2:

Another best example is a situation we always face in the internet: Complete a survey or something to enable a content to be downloaded.

My trading system needs such a thing. The dealer page always listens for the client page to act with the server. Upon such thing, the dealer page is reacted to that action. In this case placing an order.

Gopikrishna S
  • 2,221
  • 4
  • 25
  • 39
  • Look at $.ajax, it uses AJAX to send data asynchronously to web pages (in your case php) – Benjamin Gruenbaum Oct 31 '12 at 13:09
  • Thanks but I know those things, I think you couldn't get me. Whether asynchronous or not those functions have to be triggered manually or the part is to be refreshed to get the magic done. However, the thing I want is it to be automatically updated by _on its own_ – Gopikrishna S Oct 31 '12 at 13:12

2 Answers2

1

Look into a long-polling or "comet" architecture. This is widely used by event driven AJAX applications and will provide what you are looking for.

See https://en.wikipedia.org/wiki/Comet_(programming) for more info.

Rob Hardy
  • 1,821
  • 15
  • 15
1

If there is several page instances on one browser, you can use javascript web worker.

ELSE

Use "Long pooling" OR "ajax quering"

Long pooling demo: How do I implement basic "Long Polling"?

What you do, you always query server for new information. If there is new information, you return it. Then javascript will see that there is new information and it will show it.

Community
  • 1
  • 1
Ernestas Stankevičius
  • 2,420
  • 2
  • 24
  • 30