<div class="grid--cell fl1 lh-lg">
<div class="grid--cell fl1 lh-lg">
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, <a href="/help/reopen-questions">visit the help center</a> for guidance.
</div>
</div>
</div>
<div class="grid--cell mb0 mt8">Closed <span title="2012-04-09 14:07:02Z" class="relativetime">8 years ago</span>.</div>
</div>
</aside>
I know what AJAX stands for. I know javascript passably well. But frankly I'm just not clear on what AJAX is.
Because all I know about it is XMLHttpRequest(), but it must be so much more than that. Can someone give a clearer explanation of how AJAX isn't just a certain aspect of perfectly ordinary JavaScript? I can't see how it's anything different.
EDIT: I also understand that it allows you to update a page without reloading. That's fantastic, I know. But I still don't see how that's anything more than standard JavaScript.
</div>
It's a way of getting and sending data from and to the server asynchronously without refreshing the page. Data exchanged used to be just XML (the "X" in AJAX), can now be other things (e.g. JSON or even JSONP).
"Asynchronous Javascript and XML" -- you're right, it's really just a component of Javascript. From the server side, it's literally nothing: the server doesn't know or care whether it's fielding an AJAX request or a "normal" request (although of course the web application would know and care). It just happens to be famous and have a fancy acronym, because it's very useful in designing web sites.
EDIT: definition from the W3 spec http://www.w3.org/TR/XMLHttpRequest/:
The XMLHttpRequest specification defines an API that provides scripted client functionality for transferring data between a client and a server.
JavaScript happens on the client-side. Ajax uses javascript to receive a REMOTE response from the server without loading the page.
Well it's not as if it's magic or something. It really is ordinary Javascript, and it's ordinary XML (or JSON, or some other data format). And it runs in a browser. None of this is particularly new or novel. Microsoft was talking about "DHTML" in 1996, and officially released it in 1997.
But combining these existing things, is an approach that is common enough and useful enough to have earned a specific name. AJAX refers to the pattern of using asynchronous requests, driven in Javascript logic running in the browser, to retrieve data in XML format or otherwise. Typically the retrieved data is then used to update the HTML page in some way, without causing a full page refresh.
You said you don't see how that's anything more than standard JavaScript. Using Javascript in a browser you could do something as simple as run a timer that pops up an alert after it expires. Or you could perform a fadeout on a background color. Or do jQuery effects like accordion popouts. Or dynamically sort an HTML table by different columns. Even autocomplete in textboxes is possible using Javascript. These all cause the UI to be updated, but they don't necessarily retrieve any data. (in some cases autocomplete will do so, but not generally).
AJAX always involves communication and data retrieval, so it is distinct from "standard Javascript".
I think to gain an understanding you have to look into where the XMLHttpRequest came from. It was not a standard part of JavaScript at the time. You could not make asynchronous HTTP requests from the browser with pure JavaScript. The XMLHttpRequest object was first introduced by Microsoft in IE5 as an ActiveX control. So with that in mind, the way we use JavaScript today has evolved from a much simpler scenario.
I suggest you read the Wikipedia page - particularly the history section. There's nothing overtly fabulous about Ajax, it was just a coined term for what was at the time a new way of doing things, and it's stuck.
http://en.wikipedia.org/wiki/AJAX
In particular read the definitive article http://www.adaptivepath.com/ideas/ajax-new-approach-web-applications - this is probably the best way to understand where Ajax came from and indeed what it actually means. Probably most importantly
Defining Ajax
Ajax isn’t a technology. It’s really several technologies, each flourishing in its own right, coming together in powerful new ways. Ajax incorporates:
- standards-based presentation using XHTML and CSS;
- dynamic display and interaction using the Document Object Model;
- data interchange and manipulation using XML and XSLT;
- asynchronous data retrieval using XMLHttpRequest;
- and JavaScript binding everything together.
As noted, the exact definition of Ajax is quite hard to pinpoint these days. The methodologies are prone to updating themselves as the browser evolves, but these were the underlying principles at its conception.