About / FAQ

What is Ajax Cookbook?

Ajax Cookbook is a web site devoted to publishing small, reusable snippets of JavaScript, HTML, and CSS that are generally useful to developers of Ajax web sites.

The code on this site is licensed liberally under the Creative Commons Attribution 2.5 license so it can be reused in any commercial or non-commercial application, and none of the code depends on any JavaScript framework or third party library. Most of the Ajax "recipes" are just a few lines long, but solve a common problem. The goal is that you can copy and modify the code snippets extremely easily no matter what framework you are using (if any) or what your application looks like.

Why did you create Ajax Cookbook?

I created Ajax Cookbook because I saw a void in the information about Ajax programming available on the web. Most web sites that contain JavaScript or Ajax tips and tricks suffer from one or more of these problems:

  • The web site was written by a web designer who is not a software engineer, so the code is unusable, not robust, ugly, or some combination of the three. Complex web applications like Google Maps and Gmail require good software engineering principles and API design. The code in Ajax Cookbook is designed to applicable to all Ajax projects, including large ones.
  • The JavaScript snippets depend on a third party JavaScript framework, like dojo or prototype. Those frameworks are great, but if you are not using them on your project, you are out of luck.
  • The JavaScript snippets are designed for static HTML. For example, most code that fixes PNG images on IE available on the Web is geared towards replacing <img> elements in the DOM. However, most complex Ajax applications construct DOM elements dynamically, so the snippets are not reusable. The snippets in Ajax Cookbook try to make as few assumptions as possible about the structure of your site.
  • The JavaScript snippets try to create the super-works-for-everybody-API rather than just giving you the key recipe and letting you incorporate it into your project. I don't want a 2000-line class to create an XMLHttpRequest object -- I just want to know how to create it in a cross-browser way, and I can choose how to incorporate it into my project. The code in Ajax Cookbook is generally presented as a reusable function, but we don't hide the key principles of the recipe behind unnecessary abstraction that may be incompatible with the design of your project.

In short: Ajax Cookbook attempts to present well written, short, reusable code snippets while avoiding making any assumptions about the structure of your Ajax project.

What is the license for the code in Ajax Cookbook?

The content and code are available under a Creative Commons Attribution 2.5 license.

My intention was to make the code available with no strings attached for commercial or non-commercial use. If this license is unnacceptable for your project, email me, and I will try to fix the problem -- the license is not intended to be limiting to any project, but must be present for legal reasons.

I found a bug in one of your code samples. Who do I contact?

Send Bret Taylor an email, and he will update the recipe. I really appreciate bug reports, so please don't hestitate to contact me.

Who writes the content on this site?

All the content is written by Bret Taylor. I am currently the Group Product Manager for Developer Programs at Google, and before that I was the Product Manager for Google Maps and Google Local for two years. I was also the original author of the Google Maps JavaScript frontend and the Google Maps API. This site is (obviously) in no way affiliated with Google and reflects only my personal opinions, yada yada yada.

Who made the folder logo?

I got the icon from the Agua icon set made by David Lanham. The site says it's all freeware, so hopefully David won't mind. Go buy some of his impressive art on his web site when you get a chance ;)

What software did you use to create this site?

I used Django, a web site framework for Python. My experience has been generally good with it, and the performance is impressive. By far my favorite part is the automatically generated administration interface -- I basically use it as a content management system for the site, and it is something I always hated writing from scratch before.

My one complaint is that getting Django up and running with Apache is a pretty big pain. On my production web server, I am still running RedHat 9 with an old version of Python, and RPM hell makes it hard to upgrade. On my PC, I am running a recent version of Ubuntu, but even then getting Django and mod_python working happily together is non-trivial. They definitely need to integrate with apt-get and Ubuntu (which seems to be the growing standard for Linux distributions) so that getting Django up and running is more painless -- I have a feeling they have lost a few developers who gave up after fighting with mod_python and mod_rewrite for an hour.