With that, it requests the updatestatus URL and replaces the contents
of the element with the response.
You can also make regular Ajax calls through the ajax() method of the jQuery object:
CHAPTER 5 n AJAX AND DATA EXCHANGE 126
var options = {
url: 'document.xml',
type: 'GET',
dataType: 'xml',
timeout: 1000,
error: function(){
alert('Error loading XML document');
},
success: function(xml){
// do something with xml
}
}
$.ajax(options);
All options, including the URL, are sent through an object literal as the only parameter.
Summary
In this chapter you took a look at what Ajax is and what it means in comparison with traditional
page calls. You took a look at the various data exchange formats available to you and
which approach might be more appropriate for certain situations.
The chapter stepped through building a custom Ajax object. It then showed how to
extend the object to plan for contingencies. Finally, the chapter took a look at how to take
advantage of popular JavaScript libraries to handle the grunt work for you.
In Chapter 6, you??™ll take a look at visual effects and how they can be integrated into
your sites.
CHAPTER 5 n AJAX AND DATA EXCHANGE 127
Visual Effects
From animations and slides to fades, visual effects can add some sex and sizzle to a page.
While these effects can be easily overdone, you??™ll soon understand why you should add them
to a page and what problems they solve.
Pages:
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197