SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 321 | Next

Thomas Powell

"Ajax: The Complete Reference"

observe("requestButton",
"click", sendRequest);} );



PART II
C h a p t e r 5 : D e v e l o p i n g a n A j a x L i b r a r y 217






 



Prototype Ajax Assistance
So far there hasn??™t been much of a difference in the Ajax part of the Prototype library when
compared to the YUI offering. Prototype does indeed provide a number of useful
programmer assistance features. As you have already seen, a DOM element can be quickly
selected using the $() method. For example, $("ratingForm") would select the DOM
element with the id attribute set to ratingForm. Similar to the AjaxTCR DOM helper, it is
possible to pass this method many ID values to retrieve. As with YUI and the AjaxTCR
library, form contents can quickly be serialized. After retrieving an element that is a form,
you can call a serialize() method to collect the input to send with an Ajax request like
so: $("ratingForm").serialize(true). Even more useful is that it is possible to use a
simple Ajax pattern of inserting content returned into the page. Simply create an Ajax object
and use the Updater() method, passing it the target DOM element, URL to call, and
request options, like so:
new Ajax.


Pages:
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333