Chapter 12. Extending Ajax
This chapter covers
- The jQuery Ajax framework
- Adding Ajax prefilters
- Adding Ajax transporters
- Adding Ajax converters
Support for Ajax (Asynchronous JavaScript and XML) is one of the key features of jQuery, making it easy to request content from the server and to process the returned data and update the current page accordingly, without requiring a full refresh. You specify the URL to access, you can provide parameters to be sent along, and you can process the returned content in a callback function, as shown here:
jQuery also contains several convenience functions that encapsulate the Ajax abilities. For a simple request and response, you can use the get function, or to use an alternate parameter encoding, you use the post function. To load specific types of data, you can use the getScript or getJSON functions for JavaScript and JSON (JavaScript Object Notation) content respectively. If you want to place HTML content directly into an element on the page, you can use the load function on that element.
jQuery offers additional abilities to set default values for all Ajax processing and to register handlers for events that occur during the Ajax lifecycle.