What is AJAX?

What is AJAX?

Ferenc Almasi β€’ Last updated 2020 November 05 β€’ Read time 2 min read
  • twitter
  • facebook
JavaScript

AJAX stands for Asynchronous JavaScript And XML and it works in the following way:

Whenever an event occurs on a web page, eg.: a user clicks a button, an XHR request is created by JavaScript that is sent to the server. The server processes the request and returns a response to the web page which is then processed by JavaScript and the necessary actions are taken, eg.: updating the page content.

In short terms, it is a combination of using built-in browser APIs for fetching data (such as the fetch API) and DOM manipulation techniques in JavaScript to load content.

Note that while the name implies it works with XML, this is often not the case. Instead, the data is transferred as either plain text or more commonly JSON.

The pros of using AJAX include things like:

  • Updating a web page without actually reloading it
  • Request and receive data from the server after the page has been loaded
  • Send data to the server in the background

On the other hand, there are also disadvantages, such as:

  • It won’t work in case JavaScript is disabled
  • If history is not taken care of, it can make the browser’s back button useless
  • Since it increases code size, it can make your site vulnerable to security threats
What you can use AJAX for?
If you would like to see more Webtips, follow @flowforfrank

50 JavaScript Interview Questions

Resources:

  • twitter
  • facebook
JavaScript
Did you find this page helpful?
πŸ“š More Webtips
Mentoring

Rocket Launch Your Career

Speed up your learning progress with our mentorship program. Join as a mentee to unlock the full potential of Webtips and get a personalized learning experience by experts to master the following frontend technologies:

Courses

Recommended

This site uses cookies We use cookies to understand visitors and create a better experience for you. By clicking on "Accept", you accept its use. To find out more, please see our privacy policy.