1

There are gems like Faye that allow an action taken by one user to send a real-time push notification to another user, similar to facebook notifications.

Does anyone know of a way to accomplish this using only jquery and ajax?

2
  • Ajax is using http, once http completed it's task, it will disconnect from server. Unless you set interval and keep pooling from server, else you can't push from server. Another way to do this is using web socket or server sent event (SSE) Commented Jul 7, 2015 at 6:01
  • FYI, you can read Push : SSE vs WebSockets Commented Jul 7, 2015 at 6:03

2 Answers 2

2

Following on Joey Chong's answer, you can use SSE (Servent-Sent Events) to push messages to a user (Faye is based on websocket, that may be a problem with some proxies and firewalls, and it looks like you don't really need a bidirectional connection).

For more information on websockets and SSE : here and here.

If you don't want to build your SSE server or just want to test some client-side code, StreamData will allow you to turn any JSON API into SSE pushes (disclaimer: I represent this firm). It's free up to one million messages, so you can try and leave it if SSE is not what you are looking for.

Sign up to request clarification or add additional context in comments.

2 Comments

FYI, on your website I get this for the Bitcoin example: "Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at proxy.streamdata.io/https://api.bitcoinaverage.com...". I get the same for the first example too now, though that worked a while ago! FF/Ubuntu LTS/NoScript.
Thx very much for the feed-back) (and for the edit, I will remember to put the disclaimer each time). About the error message, proxy.streamdata.io is a demo proxy on which we don't guarantee SLA as no identification is required. Last week, a lot of requests were made and we reach our maximum number of connections allowed. We have risen the limits. It should work fine now on the demo proxy. You can also test it via creating a user and then we guarantee a much higher limit even in freemium.
1

No, there's no way to do that directly. But, there are some push notification APIs like Chrome Push Notification API and PushBullet which are useful if you want to send push notifications from your web application.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.