Take me back!! I want my CSS!! Click me to get back :)

Learn how to build websites,
from scratch

Start with our FREE 10-Day Bootcamp:

AJAX

AJAX is a set of technologies that makes the web highly interactive and responsive. It stands for Asynchronous Javascript and XML.

The web used to be synchronous – this means that one thing happened after another. If you wanted to search, you’d type in your term and hit “Search” and wait around for results. You’d hit “refresh” on Twitter (which wasn’t around back then) waiting to see if your friends posted any updates.

These days, though, web pages can change asynchronously – without waiting for you to do anything. New tweets will load, new Google results will show up, all without refreshing or going to a whole new page.

When Google suggests searches as you type, that’s AJAX. Your browser takes what you’ve started typing – maybe “ski” – and sends it over to the server. The server runs through a database to see what people searched for that starts with “ski.” The server sends a list of terms back and voilà! Your browser pops them into an list right under where you’re typing. And you didn’t have to do anything, so it’s asynchronous.

OK, so that’s how the A in AJAX works, but what about the rest?

The J is JavaScript. JavaScript is a programming language for your browser. Whenever things change around on a web site – slideshows, things popping up in the corner – that’s JavaScript. In the case of Google’s search suggestions, your browser is using JavaScript to ask Google for that list of terms. It’s also JavaScript that displays the list it gets back!

The last letter – X – stands for XML. Think of XML as an envelope that you can put data in. The first forms of AJAX sent XML back and forth to the server to talk. Whether it was finding tweets or search results, everything was wrapped in tiny XML packages. Some XML containing tweets might look something like this:


<tweets>
<tweet>
<username>skillcrush</username>
<text>Hey everyone, we're learning about XML!</text>
<postedOn>2012-04-18</postedOn>
</tweet>
<tweet>
<username>skillcrush</username>
<text>Hey everyone, we're learning about APIs!</text>
<postedOn>2012-04-17</postedOn>
</tweet>
</tweets>

Although it has a lot of really different pieces, AJAX boils down to allowing your browser to get information from a web server (or Google or Twitter or Facebook or whomever) without you needing to click links or refresh the page. It just makes the web a more useable place.

Cocktail Party Fact

A new way of wrapping up data called JSON is now replacing the ‘XML’ part of AJAX. If we renamed it we’d be stuck with Asynchronous JavaScript And JSON – AJAJ – though, so I’m thinking we should stick with AJAX.

Want more articles like this?

Sign up to get the most recent tech news, tips and career advice.

  • Sourabh

    Well AJAX (XmlHttpRequest) is actually used to get either XML, JSON, HTML or even plain text. If we were to rename it, best name would be textHttpRequest and maybe AJAT? sounds weird … so yeah, lets stick with AJAX

x
Wondering if TECH might be right for you?

Sign up for FREE for weekly updates & fun lessons!