Java Reference
In-Depth Information
alert(“An error occurred with the following URL:\n”
+ settings.url +”.\nStatus code: “ + request.status);
}
$(document).ajaxError(ajax_error);
The message tells the user that an error occurred, what the URL of the request was, and the HTTP status
code the server returned. With this information, you can begin to debug the error if one should arise.
jQuery is an extensive framework, and providing in-depth coverage and information requires more
than this section can provide. However, the jQuery documentation is quite good, and you can view it
at http://docs.jquery.com. jQuery's web site also lists a variety of tutorials, so don't forget to check
them out at http://docs.jquery.com/Tutorials . The inclusion of its effects/animation components
and the optional UI library makes jQuery a very versatile framework.
Diving into Prototype
jQuery is probably the most popular framework today, but that crown used to sit upon Prototype's head.
Unlike jQuery, Prototype's focus is augmenting the way you program with JavaScript by providing
classes and inheritance. It does, however, also provide a robust set of tools for working with the DOM
and Ajax support.
You were briefl y introduced to Prototype, so let's dive a little deeper into this library and see what it can
do for you with cross-browser scripting.
Retrieving Elements
When testing your Prototype installation, you were introduced to the dollar function $() . This function
is different from the jQuery function in that it simply extends the element you want to retrieve by adding
many new methods. If you pass an element's id value, then it retrieves that element and extends it with
more methods and properties.
$(“myDiv”)
This code retrieves the element with an id of myDiv from the DOM and extends it. So you can use this
extended object just like you would any other Element object, like this:
alert($(“myDiv”).tagName);
You can also pass it an Element object, which results in an extended version of that element. The fol-
lowing code passes the document.body object to the dollar function:
$(document.body)
Search WWH ::




Custom Search