Will Curran
Will Curran

Reputation: 7120

How to implement live updates on page using AJAX?

I'm using Google App Engine, Python and JQuery. My application is similar to Twitter in that it allows users to publish messages/status updates. I want the home page to display live updates (just like Twitter's homepage) so that if a new message is posted, it appears top on the list of my home page.

I'm looking for a design pattern to get started.

Upvotes: 2

Views: 642

Answers (3)

Chris B.
Chris B.

Reputation: 90329

On Google App Engine, you probably want to use the new Channel API. It allows you to declare a channel on the server, using code which looks like:

token = channel.create_channel('my_key')

... and then on the client you can use something like ...

  <script>
    channel = new goog.appengine.Channel('{{ token }}');
    socket = channel.open();
    socket.onmessage = onMessage;
  </script>

There's plenty of examples on Google's site.

Upvotes: 1

Etienne
Etienne

Reputation: 1032

There are various techniques out there, they are usually referred to as "Comet" or "Reverse Ajax". I don't know about your specific technologies, but that ought to get you on the right track.

http://en.wikipedia.org/wiki/Comet_%28programming%29

Upvotes: 0

malangi
malangi

Reputation: 2770

Have you seen the new channel api on GAE? it will basically abstract away the polling - allowing you to push bi-directionally. Oh, and i've linked to the code sample (in Python + JS).

Hope this helps

Upvotes: 4

Related Questions