Getting started with jQuery's AJAX functionality
At the heart of jQuery's AJAX functionality is the .ajax()
function. This little guy allows you to do some heavy lifting and has everything you need for all your XML HTTP Requests (XHR) needs.
For those of you with a little AJAX experience under your belts, you'll be pleased to find that in true jQuery form, this function eliminates the need for setting up the traditional if/else
statement to test for support for the XMLHTTPRequest
object and if not then, the ActiveXObject
(for IE browsers).
Using the .ajax() function
Let's take a quick look at some of the functionality available in the .ajax
call:
jQuery.ajax({ type: //"GET" or "POST", url: //"url/to/file.php", dataType: //"script", "xml", "json", or "html" data: //a query string "name=FileName&type=PDF" beforeSend://a callback function function(){ alert("Starting Request"); } success: //a callback function function(){ alert("Request successful"); } complete: //a callback function function...