Sunday, January 6, 2008

Sorting out AJAX

I've tagged a few posts here "Web 2.0", but I haven't said anything here (until just recently) about AJAX. So here's a quick take.

AJAX normally stands for three things:
  • A is for asynchronous, meaning that your browser doesn't (always) have to wait for the server it's talking to to get back to it.
  • J is for Javascript (or JScript, or more technically ECMAScript), which is one way for your browser to run custom code on its own while it's not waiting for the server.
  • X is for XML, which is XML.
For my money, these are listed pretty much in order of their importance to the picture. If you have some means of decoupling the browser from the "send request - wait for response - display response" routine, then it matters less exactly how you're telling the browser, say, how to display a list of choices that all begin with the letters you typed. It matters even less how the names behind that list happened to look on the wire when the server sent them to the GUI code the browser is running.

In theory, the browser could use any language for its scripts. ECMAscript is the choice in practice because it's close to languages like Java and C# that lots of people know [... ehhh, depends on what you mean by "close".  If you mean syntactically, sure, but the computing model underneath is notoriously idiosyncratic --D.H. Dec 2018], and more importantly because the major browsers support it.

XML is even more a matter of choice. If you're building a web page, you can define your own format if you really really want to. Or you could use JSON, or anything else you can find a library for. Not to say that there aren't arguments for using XML, just that "it's the only game in town" isn't one of them.

But you can't do any of this fun stuff without a way for the browser to take on some of the processing, and particular to be able to do that processing without waiting for a server response. The A for "asynchronous" is the essential "what" here. The J and the X are the vital but to at least some extent interchangeable "how".

No comments: