Learning Ajax
A couple of days ago, I inserted
"Now Playing"
information on my blog. As I noted, it's not extremely useful (you
cannot "listen in") - it's just geeky. I added a bit of pizazz to the
feature by adding a pop-up "tooltip" that displays a list of detailed
information about the track currently playing. The information
includes the track title, the artist, the album,
track number, track length, and a jpeg image of the cover art as well.
Again... not extremely useful, just geeky. Go ahead and move your
mouse over the "Now Playing" graphic in the upper right corner of this
blog - then wait for half a second for the information to display.
The information in the pop-up window is populated via an asynchronous
javascript call to a CGI script that just dumps the contents of a text
file. There is nothing really novel about the system (it was extremely
easy to accomplish), but this is my first experience using
Ajax
programming. Learning Ajax is one of those items on my long "To Do"
list of stuff I should learn to keep my technical skills "fresh" (just
in case I never need to start "fresh" at a new company). So I'm very
pleased I got off to a successful start after only a couple of hours
reading some on-line tutorials.
If interested in the code that accomplishes the effect, then you can
view source... here are the relevant parts of the HTML:
<div id="nowplayingtooltip"></div>
<div class="nowplaying">What I'm listening to:<br/>
<a onMouseOver="getNewContent(); ddrivetip('loading... please wait')"
onMouseOut="hideddrivetip()" onClick="openWindow(this.href, 420, 180); return false"
href="http://rus.berrett.org/now_playing/"><img id="nowplayingimg" border="0"
src="http://rus.berrett.org/now_playing/nowplaying.png"></a>
</div>
My blog's javascript code is here.
The relevant section is labeled "ajax stuff".
Note: the pop-up includes a jpeg image of the cover art. But for
whatever reason the image is not displayed in MS Internet Explorer (5,
6, or 7). Not sure why. It works great in Firefox though. *shrug*
(Update Fri Dec 28 10:05:32 PST 2007 // my -> by)
:: Posted by rus on Sat, 22 Dec 2007 11:02 pm
:: Filed under /tech
|