O'Reilly logo

Beginning JavaScript® and CSS Development with jQuery by Richard York

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Appendix G. AJAX Methods

Method

Description

Return Value

AJAX Requests

jQuery.ajax(options)

$.ajax(options)

Allows you to pass an object literal specifying various options in key, value pairs. For the complete list of options, see the "Options" section. This method is used by jQuery's other AJAX methods to make AJAX requests. You should only use this method if you require finer-grained control over an AJAX request than is possible with jQuery's other methods.

XMLHttpRequest

load(url, [data],
[function])

Loads HTML from a remote file and inserts the HTML inside of the selected elements. The data argument (optional) is specified as an object literal, defining the data you want to pass to the server in key, value pairs. The function argument (also optional) is the callback method that will handle the data once it is returned from the server.

jQuery

jQuery.get(url, [data],
[function], [type])

$.get(url, [data],
[function], [type]))

Initiates an HTTP request using the GET method.

XMLHttpRequest

jQuery.getJSON(url,
[data], [function])

$.getJSON(url, [data],
[function])

Initiates an HTTP request using the GET method, in which the response will be JSON-formatted data.

XMLHttpRequest

jQuery.getScript(url,
[function])

$.getScript(url,
[function])

Loads and executes a new JavaScript file via the GET method asynchronously.

XMLHttpRequest

jQuery.post(url, [data],
[function], [type])

$.post(url, [data],
[function], [type])

Initiates an HTTP request using the POST method.

XMLHttpRequest

AJAX Events

ajaxComplete( ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required