Thursday 28 April 2011

jQuery and Ajax


jQuery has a rich library of methods (functions) for AJAX development.

jQuery AJAX Example

Let AJAX change this text

AJAX is not a programming language.
It is just a technique for creating better and more interactive web applications.


The example above is taken from our AJAX tutorial, but modified with jQuery syntax. 

What is AJAX?

AJAX = Asynchronous JavaScript and XML.

AJAX is a technique for creating fast and dynamic web pages.

AJAX allows web pages to be updated asynchronously by exchanging small amounts of data with the server behind the scenes. This means that it is possible to update parts of a web page, without reloading the whole page.
You can learn more about AJAX in our AJAX tutorial.

AJAX and jQuery

jQuery provides a rich set of methods for AJAX web development.
With jQuery AJAX, you can request TXT, HTML, XML or JSON data from a remote server using both HTTP Get and HTTP Post.
And you can load remote data directly into selected HTML elements of your web page!

Write Less, Do More

The jQuery load() method is a simple (but very powerful) AJAX function. It has the following syntax:
$(selector).load(url,data,callback)

Use the selector to define the HTML element(s) to change, and the url parameter to specify a web address for your data.

Only if you want to send data to the server, you need to use the data parameter. Only if you need to trigger a function after completion, you will use the callback parameter.

Low Level AJAX

$.ajax(options) is the syntax of the low level AJAX function.
$.ajax offers more functionality than higher level functions like load, get, and post, but it is also more difficult to use.

The option parameter takes name|value pairs defining url data, passwords, data types, filters, character sets, timeout and error functions.


jQuery AJAX Methods From This Page:

RequestDescription
$(selector).load(url,data,callback)Load remote data into selected elements
$.ajax(options)Load remote data into an XMLHttpRequest object

No comments:

Post a Comment