santa
santa

Reputation: 12512

Push update to different user

I am trying to understand how to do the following:

I have a dashboard that is used by two different user types. One user takes an action and I update my db with submitted data using .ajax() post on a separate page. After the data is stored I return response and update this user's view with jQuery.

Now, the other user, who this data is relevant to has a portal open as well -- how do I update his view without constantly refreshing his page?

Upvotes: 0

Views: 66

Answers (2)

JasonJensenDev
JasonJensenDev

Reputation: 2407

If you need realtime information, you should consider using socket connections. For such a small project, you should check out pusher.com and sign up for their free plan. Then all you need to do is include the pusher js file and subscribe both users to the same channel. They have great documentation and examples.

Then on the backend, you could fire off an event every time a user makes a change which would alert the other user of the changes. By the way, this is how a chat system works.

Upvotes: 0

Pavlin
Pavlin

Reputation: 5528

The best way to do this without refreshing his page would be to query the server via ajax at a given interval and re-render only the data display if needed.

Upvotes: 1

Related Questions