Front End Developer — Interview Question: #03

03: Explain AJAX in as much detail as possible-JavaScript

What is AJAX?

Simply put, AJAX is the use of JavaScript to send and receive using HTTP without reloading the page. AJAX is an acronym for asynchronous JavaScript and XML, and is used as a technique for creating client-side asynchronous web applications. AJAX is considered a group of technologies. HTML and CSS can be used in combination to mark up and style information. JavaScript and the XMLHttpRequest object provide the method for exchanging data asynchronously between the browser and the server.

What is AJAX used for, and what companies use it?

Why do developers use AJAX?

AJAX provides more efficient and smoother running applications, which gives users better interactive experiences.

How does AJAX work?

AJAX, sends and retrieves data from a server asynchronously. This enables the web application to continue running and dynamically display. It allows the user to interact with the information presented on the page, avoiding full page reloads.

The image below shows the process the execution of AJAX.

  1. A user interaction in the browser triggers the event, such as a button click
  2. The AJAX call fires. This creates and AJAX request, browsers use the XMLHttpRequest object. When the server responds to the browser’s request, the same XMLHttpRequest object will process the result.

3. The server-side script receives the input from JavaScript, and processes the data.

4. After the data is processed, the script sends the data back to the original client-side page that made the request via XML

5. Once the data is received, a second JavaScript callback function, is called this function captures the data, and updates the web page accordingly.

Image Source

Note: Newer technologies have slowly been replacing the XML in AJAX with JSON. The reason being, XML is a lot stricter than HTML, thus having larger file sizes, and harder to extract the data that is returned. JSON is less verbose, has proven to be more efficient, and working with data is much easier.

View the entire list of Front End Developer Interview Questions here

Like what you read? Give Morgan Ashley a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.