ciphergoth: (Default)
[personal profile] ciphergoth

Despite being a geek, I don't actually know all that much about HTML, CSS, or all that webby stuff. The election thing was my first ever applet, and I've never known JavaScript before yesterday. But I've been thinking more about AJAX and the things you can do with it, and I think it's time I learned that stuff, because it's super cool and will be super extra hyper ace cool once SVG gets added to the mix. Here's something I've been trying today.

Because web clients generally insist on initiating all requests, the only way to keep a page up to date is usually to poll. Poll too slowly and you don't hear about changes until much later; poll too fast and you load the whole system unnecessarily.

It turns out that with AJAX you have a third option. I've just implemented a simple Web-based "tail" program with it - go to a Web page, and it shows you the tail of a file, updated in real time. The trick is basically to implement a hook in your CGI script so that if you have nothing to report, wait until you do before returning. As soon as you do have something, return it and close the connection. It's easy to be robust against timeouts so that if the connection gets closed early the client will just open it again and wait some more. The result is that the "polling" load is very low because the "polling interval" is as long as your timeouts, but once news arrives the client gets to hear about it very fast because it's hanging waiting for it.

Next, a boardgame. Or a Web-based IRC client. Or maybe a terminal emulator...

Date: 2005-05-16 11:43 pm (UTC)
From: [identity profile] brad.livejournal.com
I did this. With firefox, hit:

http://www.danga.com:8080/misc/jsdraw/xmlhttp.html

The server is Perlbal, with a plugin that keeps a long-lived (forever) HTTP connection open sending chunked content when new data arrives.

No polling.

Date: 2005-05-17 12:05 am (UTC)
From: [identity profile] deliberateblank.livejournal.com
Doesn't this approach increase the problems of having a limited number of entries in your (server-side) socket table?

Date: 2005-05-18 10:03 am (UTC)
From: [identity profile] skx.livejournal.com
Have you seen this?

http://www.danga.com/openid/

I thought it might be interesting to you, after our old discussions about identity verification to third party sites.

Date: 2005-05-19 03:49 pm (UTC)
From: [identity profile] mara1.livejournal.com
hey just saw you like Momus too - grrt band - i mean whateva!!

Profile

ciphergoth: (Default)
Paul Crowley

January 2025

S M T W T F S
   1234
5678 91011
12131415161718
19202122232425
262728293031 

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jan. 9th, 2026 07:56 am
Powered by Dreamwidth Studios