Ajax melds together existing technologies to help developers give
web users a more advanced browsing experience. By utilizing XHTML, CSS,
XMLHttpRequest object, you can turn
browsers into application platforms that closely mirror desktop
applications. This capability is allowing existing web sites to convert to
Web 2.0 sites, while increasing the number of new web applications that
can be found on the Internet today.
Ajax is giving developers a new way to create content on the Web while throwing off the constraints of the past. Web 2.0 technologies are being integrated with Ajax to give the Web a new punch that could only be achieved before with browser plug-ins. Ajax is helping to redefine how we all should look at the Web, and I hope this book puts you on the path to defining your own Web 2.0 applications.
This book is intended for two very different types of people: web developers, and project managers or other higher-level people who do not necessarily need to know the nitty-gritty details but would benefit from a general overview of how this Ajax stuff works. The different parts of the book will reflect these different audiences.
For web developers, this book assumes the following:
You have had some experience with HTML/XHTML.
You have experience using CSS, and you understand the principles behind separating presentation from content.
You are comfortable with server-side scripting in at least one language, whether it be ASP.NET, PHP, Python, or something similar.
You have some experience with relational databases and how to retrieve data from them.
This book does not expect you to be an expert in all of these skills, but it does expect that you can figure things out on your own or that you can get help from another resource (another book on the technology, perhaps) so that you can follow along with the examples presented.
Server-side code examples throughout the book will use PHP, as it seems to be the most readily understandable to the widest range of developers.
This book consists of five parts, each focusing on a different aspect of Ajax. It is certainly not necessary to read it from beginning to end, though later parts of the book do build on ideas from previous parts. The five parts of the book comprise 23 chapters and four appendixes. Part I is intended for project managers looking to get a leg up on Ajax, or for anyone who is looking for its fundamentals. The rest of the book focuses on using Ajax from a programming point of view.
Part I, Ajax Fundamentals, explains the basic technologies that form the core of Ajax and building Ajax applications:
Demonstrates how the first web sites were completely data-driven sites without the benefit of tools to improve page presentation, whereas today’s Web is completely different. From the tools that are used to develop sites to the fact that the Web is now very much driven by a combination of media and data, today is nothing like yesterday.
Explains the nature of web site construction in the past versus the applications they have become, and the fact that they require the same process and design approach utilized by developers for regular desktop applications.
Shows the technologies available on the server side of web applications, briefly discussing each and how you can use them as a backend to an Ajax application. An introduction to databases rounds out the topic.
Gives the foundation for all Ajax requests using the
XMLHttpRequest object, and
explores XML and JSON responses and their advantages and
disadvantages. Frameworks that make Ajax simpler are also
Examines the different parts of a web interface and how to lay out an Ajax application so that it is usable, functional, visually pleasing, and accessible.
Part II, Ajax Foundations, describes how these technologies are applied in an Ajax web application:
Shows the different components that make up a web application and how you can enhance them using Ajax. This chapter also explores how some Ajax techniques can break browser functionality.
Examines how to properly create a table, enhance it, and add functionality with Ajax. It also discusses the different uses for Ajax-enhanced lists.
Explores frames and
iframes and their use before XHTML was
introduced, and explains how to emulate their behavior using XML
Examines how to create navigation controls that do not rely on the default browser’s window to display messages to the user, by using Ajax to transport information back and forth between client and server.
Shows how to customize the user’s experience with an application that uses Ajax to send new data to the client when the user requests it, giving the application a Web 2.0 feel.
Shows how to handle errors thrown by the application, how to use Ajax to send messages back to the server when it is called for, and how to determine when to display errors to the user.
Examines the traditional method for animating images on the Internet, the disadvantages of using the GIF format, and the advantages of the PNG format. Then this chapter shows how you can use PNGs for animation on the Web and how to use Ajax to asynchronously download images in the background.
Explains the significance of forms on the Web, regardless of the backend markup used, and shows the additions for making forms accessible. Then this chapter examines how you can build custom form types to follow the style of the overall page, and how Ajax is used in Web 2.0 forms.
Shows how Ajax can aid in the validation of data in an XHTML form without requiring a lot of extra time on behalf of the client, and where validation should take place in a web application.
Part III, Ajax in Applications, shows you how to integrate Ajax into applications to create faster and more responsive web components:
Explores available methods for searching pages on a site, their advantages and disadvantages, and how you can leverage Ajax to bring more intelligent and helpful functionality to searching.
Examines web services and their role on the Internet, exploring the different protocols that are used—from SOAP to REST and everything in between—and shows how you can take advantage of these services with Ajax behind the scenes.
Explains how mashups are created from different web services and how Ajax can bring together services in a way that makes them even more seamless than the original mashups.
Shows how you can use the different techniques you learned in the first parts of this book to develop components for business applications, and how you can use these components to build a business mashup that has desktop application functionality.
Part IV, Wrapping Up, summarizes how to best structure Ajax applications, and how to write them with optimization in mind:
Explores techniques that you can use on both the client side and the server side of an Ajax application to make it run as quickly and efficiently as possible in light of the web technologies used.
Part V, References, contains the appendixes that refer you to important parts of Ajax development:
Discusses XML and XSLT, how to use them, and how to leverage them within a web framework.
Discusses some of the major web services currently available on the Internet, along with the protocol(s) used to implement the APIs, and whether they are free.
Discusses the major risks associated with implementing Ajax, such as security, default browser functionality, and accessibility, so that developers know what to expect regarding the Ajax and Web 2.0 technologies.
The following typographical conventions are used in this book:
Indicates new terms, URLs, filenames, and file extensions.
Indicates computer coding in a broad sense. This includes commands, options, variables, attributes, keys, requests, functions, methods, types, classes, modules, properties, parameters, values, objects, events, event handlers, XML and XHTML tags, macros, and keywords.
Constant width bold
Indicates commands or other text that the user should type literally.
Constant width italic
Indicates text that should be replaced with user-supplied values or values determined by context.
This icon signifies a tip, suggestion, or general note. You’ll also see notes regarding the WCAG guidelines. Even if you aren’t interested in accessibility specifically, these are useful best practices.
This icon indicates a warning or caution.
This book is here to help you get your job done. In general, you may use the code in this book in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission.
We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: "Ajax: The Definitive Guide, by Anthony T. Holdener III. Copyright 2008 Anthony T. Holdener III, 978-0-596-52838-6.”
If you feel your use of code examples falls outside fair use or the permission given here, feel free to contact us at firstname.lastname@example.org.
Please address comments and questions concerning this book to the publisher:
|O’Reilly Media, Inc.|
|1005 Gravenstein Highway North|
|Sebastopol, CA 95472|
|800-998-9938 (in the United States or Canada)|
|707-829-0515 (international or local)|
We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at:
You can also download the examples from the author’s web site:
To comment or ask technical questions about this book, send email to:
For more information about our books, conferences, Resource Centers, and the O’Reilly Network, see our web site at:
When you see a Safari® Books Online icon on the cover of your favorite technology book, that means the book is available online through the O’Reilly Network Safari Bookshelf.
Safari offers a solution that’s better than e-books. It’s a virtual library that lets you easily search thousands of top tech books, cut and paste code samples, download chapters, and find quick answers when you need the most accurate, current information. Try it for free at http://safari.oreilly.com.
I could never have imagined when I started writing this, my first book, just how much work and time would go into it, or how I would rely on so many others to complete this undertaking.
First and foremost, I want to thank my wife, Sarah, for her love, support, and understanding. Sarah, without you, I never would have succeeded in this endeavor. I love you with all my heart. Thank you for allowing me the late nights and countless weekends to work toward this dream. You have sacrificed so much of your life taking care of things while I could not, and for that, I do not have the words to express my gratitude.
I want to thank Kate and Tony for their understanding that Daddy was not there for the better part of a year. I hope that as you get older, you will use this as an example of knowing that your dreams are attainable with hard work. I love you both, and I hope to make up the time that I have missed. Kate and Tony, Daddy is not working on his ‘puter.
I want to thank my family, and that goes to everyone who chipped in and helped with the kids and I do not even know what else, as I worked away on my laptop. All of you gave up countless hours of your own time so that I could write. It humbles me to know I have so much love and support around me.
I want to thank Gateway EDI, Inc. for their willingness to work with me as I crunched to get this book finished. It was reassuring to know that I had that support from them, and it made it less stressful down the home stretch.
I want to thank all of my reviewers; no matter how small your contribution, I am grateful for the comments, suggestions, and corrections that I received. Thanks go to John Aughey, Prerit Bhakta, Zachary Kessin, Steve Olson, Bruce W. Perry, Stacy Trease, and Chris Wells—all of the work has been much appreciated.
I want to thank Simon St.Laurent, my editor, for calming me down when I would start to panic, working with me to give me the time that I needed, and giving me the chance to write this book in the first place. This whole process, being my first and, hopefully, not last, was made almost painless with your help and guidance. I cannot begin to thank you enough.
I also want to thank everyone else who helped get this book ready for production. Thanks to Audrey Doyle for all of the catches, corrections, and changes that have made this so much more readable. Thanks to Rachel Monaghan for all of the work you put into the production of this book, as well as the proofreading. Thank you, Karen, for giving me such a great animal! And thanks to Ellen, David, Jessamyn, and everyone else who made this book what it is.
I have spent more than a year working to see this book become a reality. Everything else in my life took somewhat of a backseat as this happened. I want everyone to know that with the publication of this book comes the completion of one of my life goals—I could not have done it without all of the support that I received.