Skip to Content
Unobtrusive Ajax
book

Unobtrusive Ajax

by Jesse Skinner
July 2007
Beginner to intermediate
57 pages
1h 43m
English
O'Reilly Media, Inc.
Content preview from Unobtrusive Ajax

Examples

It's time we really got into some more complex examples of unobtrusive development. Here, I'll go over a few typical web development challenges, complete with some fairly heavy code examples. I think it will be worth it, though, so you can see how the practice of unobtrusive development can be applied to very typical development scenarios.

These examples will be written in PHP (because it's rather common, and it's what I'm comfortable in, and I don't think anyone would benefit from trying to understand my pseudocode), but I won't be doing anything very PHP-specific, so you should be able to read along and apply the concepts to any language, even if you haven't seen PHP before in your life.

These examples will also take advantage of the JavaScript functions discussed in the previous chapter. Feel free to replace them with the equivalents in your JavaScript library.

Dynamic Ajax Tabs

Thanks to Ajax, we can make a web page look and work similar to a desktop application, complete with tabs.

Tabs were possible in the Web before Ajax, too. They just acted different. When you clicked a tab, the page reloaded, the tab was highlighted, and the appropriate content was displayed. With Ajax, the tab highlight can change with the content without reloading the page. In this example, we will get both working on the same page using Unobtrusive Ajax.

We'll start with our data—in this case, the pages themselves. A page just consists of a title and a body. Typically this will come from the database, ...

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.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Introducing Microsoft® ASP.NET AJAX

Introducing Microsoft® ASP.NET AJAX

Dino Esposito
Programming ASP.NET MVC 4

Programming ASP.NET MVC 4

Jess Chadwick, Todd Snyder, Hrusikesh Panda
Windows XP in a Nutshell, Second Edition

Windows XP in a Nutshell, Second Edition

David A. Karp, Tim O'Reilly, Troy Mott
Adopting .NET 5

Adopting .NET 5

Hammad Arif, Habib Qureshi

Publisher Resources

ISBN: 9780596510244Errata