COWS Ajax - Ajax evolved
COWS Ajax takes over where Ajax leaves off. The web has gone through a great period of experimentation and now there is a dizzying array of frameworks, add-ons, how-to’s, and books. The common element these Ajax aides all fail to overcome is that, even with aides, apps take a long time to create and debug. Many times someone has already created a great tool and you’d really just rather use theirs instead of reinventing the wheel (especially if it’s a Google, Yahoo, or other trusted player). Wouldn’t it be great to drop in a single-line of code to gain a huge amount of functionality that frees you for something else? You can’t do that with Ajax, but you can with COWS (Changeable Origin Web Services) Ajax. Now highly interacticve third party services like SpellingCow are possible.
The classic Ajax example is to auto-complete the user’s city/state after they enter their zip. Peachy... but how many developers have access to an up-to-date zip code databases? Wouldn’t it be better for the US Post Office to create a tool that you could simply access from your web app/page? You should be able to drop in a single-line of code that handles zip lookups and frees you up to work on the meat of your app/site. This isn’t possible with Ajax, and that’s where COWS Ajax takes over.
The first real-world COWS Ajax powered app is SpellingCow. It’s not sexy, it’s a spell checker. But it’s cool in that it allows you to spell check as-you-type. Perhaps you’d like to have spell checking on your page/app, but don’t have the time to go create one. But now you can just use SpellingCow to handle all the processing, allowing the user to communicate with both your site and SpellingCow. Still not convinced? Check out the SpellingCow favelet and explain how you’d do that with Ajax! You can’t! You can bring a COWS Ajax powered app with you to any site you visit!
Apps like SpellingCow simply are not possible with Ajax. The short story is that Ajax must adhere to the browser same-origin policy, meaning that the user can only talk back to your site, and no others. COWS Ajax is able to breakdown this barrier via a method known as dynamic script tags. Like Ajax, it’s a method that has been around for a long time (and works in many browsers & versions). I actually independently discovered the method in the middle of 2006 since the approach has not received much prior attention. No one has really tapped into its full power, and really SpellingCow is just the tip of the iceberg. There’s no telling what a Google or Yahoo could produce.
The beauty is that really anyone with a valuable resource can probably come up with a killer app. There’s no reason why you, as a developer, could not create some fantastic service. Through COWS Ajax, you now have a viable method of distributing it with minimal effort. Folks simply add a one-liner to their page and they are able to fully utilize your service on their site and in conjunction with any other services they may be running. Not to mention the possibilities from creating a favelet. In return for offering a service, you could insert ads, accept subscriptions, or increase brand awareness (like a USPS logo in the previously mentioned example).
The COWS Ajax web site has an in-depth explanation of how it works so we’ll explain here in general terms. As mentioned, dynamic script tags are the driving force behind it. Let’s say you, as a site user, are connected to a page on xyz.com that is also using SpellingCow, the out-of-origin server you couldn’t normally access via Ajax. Each time you need to talk to SpellingCow, you dynamically insert a