Search within TutorialsPark

Jquery Ajax: Get and Post Method


Learn to use jQuery Ajax Get and Post Request Methods and Applications


jQuery Ajax : GET and POST Method

The ajax method can accept different types of parameters, and can POST data to or GET data from the Server.


jQuery Ajax: Making Request Using $.get()

The jQuery $.get(URL, data, sucess_callback, data_type) is used to initiate a GET request to the server using the specified URL with any passed parameters as the query string. The parameters are as follows:

The parameter URL specifies the resource to be accessed using the GET request

The second parameter data specifies the data that need to accompany the request.

The parameter sucess_callback is a function that gets invoked upon successful completion of the request.

The last parameter data_type is used specify the type of data expected from the server.Possible values can be html , xml , json etc.

Example: Making Request Using $.get() Method

Give it a TRY! » Note: The method parent() can go only one level up the DOM.


jQuery Ajax: Making POST Request Using $.post()

The jQuery $.post(URL, data, sucess_callback, data_type) is used to initiate a POST request to the server using the specified URL, with any parameters passed within the body of the request.

The parameters are same as the GET method but used to POST requests.

Example: Making POST request using $.post() method

Give it a TRY! » Note:The method parents() selects all parents.


jQuery Ajax : Making Requests Using $.getJSON() Method

The jQuery $.getJSON(url, parameter, callback) method is used to initiate a GET request to the server using the specified URL, with any passed parameter as the query string.

The response is interpreted as a JSON string, and the resulting data is passed to the callback function.The $.getJSON() method is similar to $.get() is that it issues a GET request to a server-side resource.

Example: Making Request Using $.getJSON() Method

Give it a TRY! » Note:If no matches are found , then all the ancestors are selected.


jQuery Ajax : Using the $.ajax() Method

The jQuery method $.ajax(property1:value, property2:value) is the mother of all Ajax Methods, all other methods like $.get() and $.post() in the background use the $.ajax() to get the job done, since all other methods lack advanced features.

The method accepts a JavaScript object as its parameter, with various configuration settings to be used while making an Ajax request, there are 20 such options available.

Example: jQuery Method ajax()

Give it a TRY! » Note:It returns a wrapped set containing the single nearest ancestor that matches the passed expression.


jQuery Effect: jQuery stop() Method

The jQuery method stop() is similar to closest() method, it finds the first ancestor that has a value for the CSS position property of relative , absolute or fixed.

These elements are known as positioned ancestors , these properties can be used while working with animation.

Example: Selecting Ancestors using offsetParent() Method

Give it a TRY! » Note:This method works its way up the hierarchy until it reaches an element with one of the required values.


jQuery Effect : jQuery delay() Method

The jQuery method delay() is used to delay all unexecuted functions in the named queue.

Example: jQuery delay() Method

Give it a TRY! » Note:This method works its way up the hierarchy until it reaches an element with one of the required values.