Open In App

What are the protocols used by Ajax ?

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:

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

HTTP is stateless protocol

HTTP protocol runs on port number 80.

HTTP Headers Fields

  1. General
  2. Response 
  3. 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

HTTPSHTTPS 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:

Some cases XMLHTTPRequest also supports ftp or ftps protocol.

The types of request that you can make using HTTP/HTTPS/FTP/FTPS:

Example:




<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",
     
    // Send request to server
    xhrReq.send();
</script>

Output:

 


Article Tags :