Tuesday, 27 October 2015

jQuery - Ajax

Ajax

- It stands for Asynchronous Javascript and XML and it enables to receive requesting data from a server without scene change of the page that you are looking at. Also, we are going to know the way of retrieving external data from XML or JSON.

- In the difference between synchronous way and asynchronous, synchronous can execute next action after receiving response back from the server while asynchronous way can take next action without response from the server.

Purpose 

- For exchanging information such as XML, JSON, TEXT and (X)HTML between a client and a server without scene change. In other words, Ajax enables that the client computer can receive requesting data from server without scene change.

Example

- When you write a comment on a blog or internet cafe, it is possible to do that without page change. Which is implemented by Ajax.

Methods

load() - It is used for retrieving external content

$(element).load(url, data, call back function)
ex) $("#d1").load("documnet_1.txt"); // all the content from document_1.txt and remve all the sub element of


$.ajax() -

It is possible to transmit a data through the way of HTTP, POST and GET. This is an integrated method that could request data from the type of (X)HTML, XML, JSON and TEXT.
In other words, it is considered as a mixed function with $.post(), $.get() and $.getJSON().

$.post() 

- It is used for receiving a response from a server after transmitting a data to the server in the way of HTTP POST.

$.get() 

- It is used for receiving response request to the server after transmitting a data to the server in the way of HTTP GET.

$.getJSON() 

- It is used for receiving a response of the JSON formation from the server after transmitting a data to the server in the way of HTTP GET.

$.getScript() 

- It is used for calling external javascript by using Ajax

$.ajaxStop(function(){ ... }) 

- Exec statement is executed in the function once response request to the server is complete in the asynchronous way.

$.ajaxSuccess(function(){ ... })

- Exec statement is executed in the function after completing ajax request successfully.

serialize()

- When the input value is transmitted by a visitor, data is transmitted to action page after converting to query string formation like 'name1=value1 & name2 = value2 ...'.

serializeArray() 

- Description is same with serialize() but converting to JSON data like key1:value1, key2:value2 ...

ajaxComplete(function(){ ... })

- Exec statement is executed if Ajax communication is finished.



No comments:

Post a Comment