Friday, October 12, 2012

jQuery Ajax Tutorial

jQuery provides a set of methods and events to perform Ajax calls to the server. JQuery has a set of flexible methods which allows us to send requests to the server in different formats and get data from the server in various formats based on the need.

Supported Request Types
jQuery supports both the HTTP GET and HTTP POST request types to send requests to the server.

Supported Data Formats
jQuery can handle data returned from the server in any of these formats.
XML
HTML
Text
JSON
Script

JQuery provides different methods to make Ajax requests based on the type of request and the type of data returned from the server, the following are the list of options available in jQuery to perform an Ajax call.

Method
Description
ajax()
This is the most common Ajax method provided by jQuery, this method can handle both GET & POST requests and can handle the return data in any format (XML, HTML, Text or JSON)
get()
Sends a HTTP GET request to the server, can handle the return data in any format (XML, HTML, Text or JSON)
post()
Sends a HTTP POST request to the server, can handle the return data in any format (XML, HTML, Text or JSON)
load()
Sends a HTTP GET or POST request to the server, handles return data in HTML format and directly assigns the returned HTML into a page element like DIV, SPAN, etc

Eg: $('#DivResult').load('test.html');
getJSON()
Sends a HTTP GET request to the server, handles return data in JSON format.
getScript()
Sends a HTTP GET request to the server, handles return data in script format, automatically executes the script which is sent from the server.

Related Post
What is Ajax?
jquery ajax Tutorial


Search Flipkart Products:
Flipkart.com

No comments: