🎉 We just launched a new HTML course! Get 3 courses with 33% off! 🎉
What is AJAX?

What is AJAX?

Ferenc Almasi • 🔄 2020 November 05 • 📖 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
Looking to improve your skills? Check out our interactive course to master JavaScript from start to finish.
Master JavaScript

Resources:

Did you find this page helpful?
📚 More Webtips
Frontend Course Dashboard
Master the Art of Frontend
  • check Unlimited access to hundreds of tutorials
  • check Access to exclusive interactive lessons
  • check Remove ads to learn without distractions
Become a Pro

Recommended