Skip to Main Content
Adding Ajax
book

Adding Ajax

by Shelley Powers
June 2007
Intermediate to advanced content levelIntermediate to advanced
400 pages
9h 52m
English
O'Reilly Media, Inc.
Content preview from Adding Ajax

Mixer: SVG and Ajax

The implementation of SVG within browsers is still very young, but the commitment is there, and as new versions of browsers are rolled out, we have stronger integration between SVG elements and regular web elements. This is my way of saying that the examples mixing SVG and Ajax are limited primarily to Firefox and Opera, WebKit (mostly), and rarely, IE. I've avoided working within such limitations in the book, but we're due for a little fun. For your own production needs, you can use embedded SVG and script, and if you use an iframe, you can communicate between the two environments. You might want to restrict the use for nonessentials.

In Example 8-10, we will take the paginated example from Example 8-1 and add a "popularity bubble." A small SVG circle is embedded below the pagination table. Moving the mouse over the table highlights rows as it goes, setting the row background to red, and then back to gray after the mouse passes. The number of comments for each post, located in the last cell of the table row, is accessed, and its value is used to determine how big the SVG circle is, from no size at all for zero comments, to larger for more commented posts.

The additions to the JavaScript from Example 8-2 would be quite small except for the problem of having to deal with browser differences. Inline SVG isn't supported in enough browsers, so the SVG is created in a separate file and then loaded into a web object. When the page is loaded, depending on whether the ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Ajax: The Definitive Guide

Ajax: The Definitive Guide

Anthony T. Holdener III
Ajax Design Patterns

Ajax Design Patterns

Michael Mahemoff
Web Development with JavaScript and Ajax Illuminated

Web Development with JavaScript and Ajax Illuminated

Richard Allen, Kai Qian, Lixin Tao, Xiang Fu

Publisher Resources

ISBN: 9780596529369Supplemental ContentErrata Page