(^210) ❘ CHAPTER 7 AJAX
Using AJAX Event Methods
The preceding example defi nes events globally using the $.ajaxSetup() method. In the following
example, Example 7-7, I demonstrate how to do the same using individual jQuery AJAX event
methods. Only the script for the preceding example, Example 7-6, has been modifi ed:$(document).ready(
function()
{
$(document)
.ajaxSend(
function(event, request, options)
{
if (decodeURI(options.url).indexOf('Example 7-7') != -1)
{
$('div#folderActivity').show();
}
}
)
.ajaxSuccess(
function(response, status, request)
{
if (decodeURI(options.url).indexOf('Example 7-7') != -1)
{
$('div#folderActivity').hide();
}
}
)
.ajaxError(
function(request, status, error)
{
if (decodeURI(options.url).indexOf('Example 7-7') != -1)
{
$('div#folderActivity').hide();
}
}
);$('img.folderTreeHasChildren').click(
function()
{
var arrow = 'tree/down.png';if (!$(this).next().children('ul').length)
{
$(this).next()
.load(
'Example%207-7/' +
$(this)
.prev()
.data('id') + '.html',
function()
{
$(this)