09.02.2015 Views

DOM Traversal Methods - MarkMail

DOM Traversal Methods - MarkMail

DOM Traversal Methods - MarkMail

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

AJAX <strong>Methods</strong><br />

Shorthand <strong>Methods</strong><br />

These methods perform the more common types of AJAX requests in less code.<br />

$.get()<br />

Loads data from the server using a GET HTTP request.<br />

$.get(url[, data][, success])<br />

Parameters<br />

• url: A string containing the URL to which the request is sent<br />

• data: (optional): A map of data that is sent with the request<br />

• success: (optional): A function that is executed if the request succeeds<br />

Return Value<br />

The XMLHttpRequest object that was created.<br />

Description<br />

This is a shorthand AJAX function, which is equivalent to:<br />

$.ajax({<br />

url: url,<br />

data: data,<br />

success: success<br />

});<br />

The callback is passed the returned data, which will be an XML root element or a text<br />

string depending on the MIME type of the response.<br />

Most implementations will specify a success handler:<br />

$.get('ajax/test.html', function(data) {<br />

$('.result').html(data);<br />

$().log('Load was performed.');<br />

});<br />

This example fetches the requested HTML snippet and inserts it on the page.<br />

[ 154 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!