How AJAX works.

Isaac Avilez
2 min readJan 6, 2021

--

If you’re a web developer, I’m sure you’ve used fetch() before, but have you ever used AJAX? Or even heard of it for that matter?

Basically, in short, AJAX means Asynchronous JavaScript And XML.

Similar to fetch, AJAX will provide you with the same:

  • Update a web page without reloading the page.
  • Request data from a server — after the page has loaded.
  • Receive data from a server — after the page has loaded.
  • Send data to a server — in the background.

Keep in mind that AJAX is not a programming language.

The way that AJAX works is simply listed as such:

  • An event occurs in a web page (the page is loaded, a button is clicked).
  • JavaScript generates an XMLHttpRequest object.
  • A request is sent to a web server by the XMLHttpRequest object.
  • Request is processed by the server
  • The server sends a response back to the web page
  • The response is read by JavaScript
  • JavaScript performs the correct action.

Here is an image that will also help understanding how AJAX works:

AJAX in action.

AJAX is also supported by ALL modern browsers. To handle IE5 and IE6, check if the XMLHttpRequest object is supported by the browser, or else build an ActiveX: object.

I hope this blog helps you understand how AJAX works, and will help you in your coding future.

--

--