Demo 3 : a random tune

AJAX

OK, finally we're at a true AJAX page.

Again, to see this work - at least in FireFox - you should disable FireBug. (Or maybe I'm just missing an option somewhere.

This time, when you expand the 'random tune' box, you get one. Voila.

In the typical AJAX tradition, I've implemented this with a server side script which in this case generates the HTML for the expanded box. However, if instead there were a long list of static files on the server, the JavaScript code could have just grabbed one of 'em at random - which wouldn't have required any server-side programming.

The 'asynchronous' part is that the random tune updates while the box is collapsed; an HTTP get request is fired off, and a handler catches the HTML chunk and stuffs it in place.