Front End Developer — Interview Question: #03
What is AJAX?
What is AJAX used for, and what companies use it?
- Login forms — digg.com
- Auto-complete with the search bar — google.com
- Voting and rating content — reddit.com
- Updating user content — twitter.com
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.
- A user interaction in the browser triggers the event, such as a button click
- 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.
4. After the data is processed, the script sends the data back to the original client-side page that made the request via XML
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