What are the protocols used by Ajax ?
Last Updated :
02 Jun, 2022
In this article we will go to cover what really Ajax means, Asynchronous, and how it makes requests to the server using XMLHTTPRequest and the protocols used by ajax, basically HTTP and HTTPS.
AJAX: AJAX stands for Asynchronous JavaScript And XML. It is about updating a web page without reloading the entire web page. This is very useful when only some parts of a web page need to be changed. It can send and receive information in various formats, including JSON, XML, HTML, and text files.
Features of Ajax:
- Asynchronous means before completing the first request can proceed to further request to fulfill so there is no need to wait for the request to complete and the operations on the client do not get blocked. This means, that the client can work on other things and does not need to wait for the response. Examples of asynchronous calls in JavaScript are - setTimeout(), setInterval(), etc.
- AJAX is not a programming or a scripting language. It relies on the interplay of a few different technologies and requires a little knowledge of each.
- The group of inter-related technologies like JavaScript, XML, HTML, XHTML, CSS, JavaScript, DOM, XML and XMLHTTPRequest.
- AJAX uses different protocols to exchange data between browser and server. AJAX communicates asynchronously with the server using the XMLHttpRequest object.
Protocols: Set of rules defined for communication.
AJAX mainly create request to the server for two protocols:
For this request to make to the server need an instance for that XMLHTTPRequest to have the functionality to send these protocol request asynchronously
HTTP - HTTP means HyperText Transfer Protocol. It is the protocol used by the World Wide Web(www) that defines how messages are formatted and transmitted. HTTP is a stateless protocol. because the server does not require to maintain information or status about every user for the duration of multiple requests and does not need to maintain a continuous connection with the client.
Features of HTTP:-
HTTP is an application layer protocol and typically uses TCP
- Tcp tries a retransmission when packet loss is detected .
- Tcp header is not encrypted so http is not encrypted protocol
- In Http communication between webservers and clients
- HTTP work to get requests and give responses.
HTTP is stateless protocol
- The server opens a connection for every request and closing it after the response has been sent.
- every request in html is completely independent
- In http, programming , local storage , cookies, sessions are used to create enhanced user experiences.
HTTP protocol runs on port number 80.
HTTP Headers Fields
- General
- Response
- Request
Steps in HTTP requests processing -
1.Client requests a connection with the server
2.The server opens a connection with the client
3.The client makes a request to the server
4.The server processes the request
5.The server sends a response to the client
6.The client closes the connection
HTTPS -HTTPS stands for Hyper Text Transfer Protocol Secure It is just a secure version of HTTP. It uses TLS(Transport security layer)/SSL(secure socket layer) encryption over the HTTP protocol . Before request is sent , SSL encryption takes place at the transport level. So here all the request is same as HTTP. So everything in the request is encrypted. Example : credit card data , social security number etc
Features of HTTPS:
- communication between webservers and clients
- Http requests / responses.
- Data sent is encrypted
- Increase security of data transfer.
- SSL/TSL used
- Install certificate on web host.
- Run on port number 443
Some cases XMLHTTPRequest also supports ftp or ftps protocol.
The types of request that you can make using HTTP/HTTPS/FTP/FTPS:
- GET: It requests for a data.
- HEAD: It requests for data but without the response body.
- POST: It submits data causing a change in state on the server.
- PUT: It replaces the specified data with request data.
- DELETE: It deletes the specified data.
- CONNECT: It establishes a tunnel to the server.
- OPTIONS: It describes the communication options for the target data.
- TRACE: It perform message loop-back test along the path to the target data.
- PATCH: It apply partial changes to data.
Example:
JavaScript
<script>
//create new request through constructor
const xhrReq = new XMLHttpRequest();
// Set up listener
xhrReq.onload = () => {
// Get response from the server
let resJSON = JSON.parse(xhrReq.response);
console.log(resJSON);
};
// Open url and get new created request
xhrReq.open("get",
"https://dog.ceo/api/breeds/list/all", true);
// Send request to server
xhrReq.send();
</script>
Output:
Similar Reads
Explain Technologies that are used by AJAX
In this article, we will see the different technologies used by AJAX. Ajax is an acronym for Asynchronous Javascript and XML. It is used to communicate with the server without refreshing the web page and thus increasing the user experience and better performance. It is a technique, & not a progr
5 min read
What are the types of post back in AJAX ?
Post Back in Ajax is the process of requesting information from the server by making an Ajax Request. We can provide a JavaScript event handler on the appropriate client event of the control that should initiate postback requests. For instance, a postback request happens when we click on a button/li
4 min read
What is the use of jQuery.ajax() method?
AJAX is an important concept that must not be missed if you are learning front-end web development. It is an important aspect of the JavaScript programming language that allows the website to make requests to the server and exchange data without disturbing the page, that is without having it reload.
6 min read
What are the uses of XMLHTTPRequest Object in Ajax ?
In this article, we will know about the XMLHTTPRequest and how it can be useful for client-server request and properties of XMLHttpRequest.XMLHTTPRequest is an object that sends an HTTP request to the server and interacts with the server to open a URL and retrieve data without loading the complete p
3 min read
Which parameters are being used for the jQuery Ajax method ?
In this article, we will see the parameters that are used in the jQuery Ajax method along with understanding their implementations through the illustrations. The ajax() method in jQuery is used to perform an AJAX request or asynchronous HTTP request. Generally, the ajax() method is used in all the r
6 min read
Types of Network Protocols and Their Uses
Network protocols are a set of rules that are responsible for the communication of data between various devices in the network. These protocols define guidelines and conventions for transmitting and receiving data, ensuring efficient and reliable data communication. What is Network Protocol?A networ
9 min read
What is data-ajax attribute?
The data-ajax attribute is a custom HTML attribute used for storing AJAX-related information in an element, guiding JavaScript interactions, and AJAX requests for dynamic content loading or updates. The data-ajax attribute allows to activation of unobtrusive AJAX. Unobtrusive AJAX is an add-on on jQ
3 min read
What are the security issues with AJAX ?
AJAX (Asynchronous JavaScript and XML) is a powerful web development technique that allows websites to retrieve data asynchronously from a server without refreshing the entire page. While AJAX offers numerous benefits, it also introduces some security concerns that developers need to be aware of. Th
6 min read
What is an asynchronous request in AJAX ?
In this article, we will have a deep look into Asynchronous AJAX requests. Basically, AJAX provides two types of requests namely Synchronous AJAX and Asynchronous AJAX. Asynchronous requests in AJAX don't wait for a response from the server whereas synchronous waits for the response. When asynchrono
3 min read
What is ATP (AppleTalk Transaction Protocol)?
ATP stands for AppleTalk Transaction Protocol. It is a part of a series of networking protocols called the âAppleTalkâ developed by Apple Inc. It is a transport layer protocol that lets you transfer small amounts of data across a network. It provides an error-free and reliable means of communication
5 min read