DEV Community

Adam Roynon
Adam Roynon

Posted on

What is AJAX?

Ajax, or Asynchronous JavaScript And XML, is a way to request a resource from the server without having to reload the page or ask the user to navigate to a different page. This means you can request information, such as recent posts, in the background and refresh the display in the foreground dynamically with the new information. This can be referred to as real-time communication between the server and the client or real-time updating.

The name AJAX is misleading as it doesn't have to be XML that is transferred. More often than not it is JSON or plain text that is transferred from the server. JSON is more human-readable and lightweight when comparing to XML. However, it doesn't matter what data or format you transfer with AJAX as it can support any data, in any format.

Before the use of AJAX to get information from the server you had to reload the page and have some inline scripts within the page that is processed on the page prior to the user receiving it. By this I mean, having an HTML document with some PHP code inline to load all the newest posts and displaying them to the user. This would mean to get any new posts the user would have to reload the page to get the new information. However, with AJAX you could have an endpoint on the server to receive the newest posts and then use a client-side scripting language, such as JavaScript, to periodically send AJAX requests to receive the newest posts and update the display without requiring a page reload.

This post was originally published on https://acroynon.com

Top comments (0)