AJAX - The Complete Reference

(avery) #1

220 Part II: Applied Ajax^


function logRequest(request)
{
$("log").innerHTML += "<strong>Request:</strong>" + request.url + " sent.<br />";
}

NNOT EOTE You can call Ajax.Responders.unregister(responder) to disassociate a responder
with a particular event, but you will need to have saved a reference to the object when you
initially bound events (var responder = Ajax.Responders.register(); ) since you
need to pass that value to this method.

Exploring Prototype Further

Like YUI, Prototype 1.5 covers the basics and adds some nice conveniences, but it really could
go a lot further. Ajax communication capabilities are only part of what all the fuss about
Prototype is about. The library provides numerous features that can make JavaScript far easier.
Take a look at a few of Prototype’s interesting selection and utility functions in Table 5-9.
You’ll see there are numerous very convenient calls that can significantly reduce your
JavaScript efforts.
Table 5-10 shows even more facilities that you might find valuable in your Ajax coding
efforts, particularly when dealing with query strings and JSON responses. However, if you

Function Description Example
$ A shortcut for document
.getElementById() and
more. You can pass this
function a single string or
element and it will return either
the element or the document
.getElementById() on the
string. You can also pass it a
list of strings or elements and
it will return an array of the
elements.

var node = $('myDiv');

TABLE 5-9 Sample of Useful Prototype Facilities
Free download pdf