PDA

View Full Version : Open-source AJAX libraries


BigBison
April 9th, 2006, 03:08
This article describes Prototype, an open source JavaScript library to create an object for an AJAX application. I explain how to use Prototype by describing an environmentally oriented web application that displays an annual atmospheric carbon dioxide (CO2) level. First, I will discuss Prototype's benefits and describe how to set up Prototype in your application. Second, I will delve into the nitty-gritty of how this application puts the library to good practical use.

Why Prototype?

Why didn't I just create a plain old JavaScript object (POJO) for my application, instead of introducing an open source library? For one, Prototype includes a nifty collection of JavaScript shortcuts that reduce typing and help avoid the reinvention of the wheel. The commonly touted shortcut is $("mydiv"), which is a Prototype function that returns a Document Object Model (DOM) Element associated with the HTML tag with id "mydiv". That sort of concision alone is probably worth the cost of setting up Prototype. It's the equivalent of:

document.getElementById("mydiv");

Another useful Prototype shortcut is $F("mySelect"), for returning the value of an HTML form element on a web page, such as a selection list. Once you get used to Prototype's austere, Perlish syntax, you will use these shortcuts all the time. Prototype also contains numerous custom objects, methods, and extensions to built-in JavaScript objects, such as the Enumeration and Hash objects (which I discuss below).

Finally, Prototype also wraps the functionality of XMLHttpRequest with its own Ajax.Request and related objects, so that you don't have to bother with writing code for instantiating this object for various browsers.

http://www.xml.com/lpt/a/2006/04/05/prototype-javascript-ajax.html

Digiscape
April 9th, 2006, 03:44
I've been trying to choose a JavaScript framework or DHTML library over the last few days and Prototype has a good reputation, the lack of documentation is a little scary for a newbie like me, the library http://script.aculo.us (http://script.aculo.us/) builds on Prototype and is now included in Ruby on Rails

The open source Dojo toolkit http://dojotoolkit.org also got my attention, they appear to take accessiblity and standards seriously

On a side note W3C has put up a draft for XMLHttpRequest spec
http://www.w3.org/TR/2006/WD-XMLHttpRequest-20060405/

EDIt: Just found the Protype documentation on the script.aculo.us wiki
http://wiki.script.aculo.us/scriptaculous/show/Prototype

sea otter
April 14th, 2006, 06:30
There's an excellent tutorial on using prototype here:

http://www.sergiopereira.com/articles/prototype.js.html

I haven't found anything better yet, and I found it invaluable for learning how to extend prototype and script.aculo.us.