What Does Ajax Mean?

With a blog name like Ajaxonomy I would imagine that most users already have a definition of Ajax. Most of you already know that the term Ajax was coined by Jesse James Garrett and the term stands for Asynchronous JavaScript And XML. The method used to accomplish the Asynchronous (the main thing to remember regarding this is that it makes it so you don't need to refresh the page with every request) retrieval of the data is the JavaScript XMLHttpRequest object.

Below is an example of a simple JavaScript object for making an Ajax connection (Please note that there are quite a few great libraries that have similar code that may be a better fit for your application).

//Ajax Object Code
var net=new Object();
net.READY_STATE_UNINITIALIZED=0;
net.READY_STATE_LOADING=1;
net.READY_STATE_LOADED=2;
net.READY_STATE_INTERACTIVE=3;
net.READY_STATE_COMPLETE=4;
net.ContentLoader=function(url, onload, onerror, callingobject){
	this.url=url;
	this.req=null;
	this.callingobject=callingobject;
	this.onload=onload;
	this.onerror=(onerror) ? onerror : this.defaultError;
	this.loadXMLDoc(url);
};
net.ContentLoader.prototype={
	loadXMLDoc:function(url){
	        if(window.XMLHttpRequest){
	                this.req=new XMLHttpRequest();
	                if (this.req.overrideMimeType) {
          			 this.req.overrideMimeType('text/xml');
		        }
	        } else if (window.ActiveXObject){
	                try {
           			this.req=new ActiveXObject("Msxml2.XMLHTTP");
			} catch (err) {
				try {
					this.req=new ActiveXObject("Microsoft.XMLHTTP");
			} catch (err) {}
			}
	        }
	        if(this.req){
	                try{
				var loader=this;
	                        this.req.onreadystatechange=function(){
	                                loader.onReadyState.call(loader);
	                        };
	                        var TimeStamp = new Date().getTime();//This fixes a cache problem
	                        if(url.indexOf("?")<0){
		                        this.req.open('GET', url+"?timestamp="+TimeStamp, true);
	                        }else{
	                                this.req.open('GET', url+"×tamp="+TimeStamp, true);
	                        }
	                        this.req.send(null);
	                } catch (err){
	                        this.onerror.call(this);
	                }
	        }
	},
	onReadyState:function(){
	        var req=this.req;
	        var ready=req.readyState;
	        if(ready==net.READY_STATE_COMPLETE){
	                var httpStatus=req.status;
	                if(httpStatus==200||httpStatus===0){
	                        this.onload.call(this);
	                } else {
	                        this.onerror.call(this);
	                }
	        }
	},
	defaultError:function(){
	        alert("error fetching data!" + "\n\nreadyState: "+this.req.readyState + "\nstatus: "+this.req.status+"\nheaders: "+this.req.getAllResponseHeaders());
	}
};

I have found that there are three main interpretations on the meaning of Ajax.

  1. Asynchronously retrieval of data through the JavaScript XMLHttpRequest object which is always XML
  2. Asynchronously retrieval of data through the JavaScript XMLHttpRequest object which can be XML or JSON
  3. Asynchronously retrieval of data through the JavaScript XMLHttpRequest object which can be XML, JSON, HTML or any text string

Since Jesse James Garrett coined the term we should see what he says about the above. According to the question and answer section of Jesse's essay (click here to read the essay) Jesse appears to side on the latter two of the above meanings.

I personally like the last definition as it allows for me to be more flexible in designing my applications. Because of this whenever you hear me refer to Ajax I will be referring to the last definition. I know that you probably have a definition that you like and I would love to hear your favorites, so leave your favorite definition in the comments.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <pre> <div> <blockquote> <object> <embed> <img> <param>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Copy the characters (respecting upper/lower case) from the image.