Ajax, shorthand for Asynchronous JavaScript and XML, is a web development technique for creating interactive web applications. The intent is to make web pages feel more responsive by exchanging small amounts of data with the server behind the scenes, so that the entire web page does not have to be reloaded each time the user makes a change. This is meant to increase the web page’s interactivity, speed, and usability.
Basically, a regular AJAX-like implementation includes two main components: a client HTML page with JavaScript code making an AJAX call and receiving a response, and a remote page that can accept a request and respond with the required information. The JavaScript code on the client page is responsible for instantiating an XmlHttp object, then providing this object with a callback method which will be responsible for processing the received information, and finally, sending a request to the remote page via the XmlHttp object. All this is done by the JavaScript code.
So, what exactly are the pros and cons of using AJAX for web development?
Pros Cons ---- | ---- Websites do not need to Different JavaScript imple- reload to transmit their mentation in every browser data to the server. with proprietary extensions. Since, you do not need to Small requests less than 512 reload to transmit data bytes may only be sent using this can aid in greater AJAX currently. UI flexibility/usability. AJAX extends the browser AJAX can break if a user presses with lightweight mini- the "Back" Button. applications. AJAX adds portability AJAX can be affected by a slow due to it's backend Internet connection since it history. must connect to the server to receive its data. Most importantly it is Since the Ajax web pages are updated easy to implement. dynamically, it becomes difficult to bookmark a state of the page. Relies on JavaScript -- which not everyone has enabled for security purposes. Ajax interfaces are harder to program than Rich Interactive Internet Applications (RIAs) (XHTML/DHTML snippets) and also give programmers less control.
Take a look at some of the code:
function GetXmlHttpObject(handler)
{
var objXmlHttp = null;
if (!window.XMLHttpRequest)
{
// Microsoft
objXmlHttp = GetMSXmlHttp();
if (objXmlHttp != null)
{
objXmlHttp.onreadystatechange = handler;
}
}
else
{
// Mozilla | Netscape | Safari
objXmlHttp = new XMLHttpRequest();
if (objXmlHttp != null)
{
objXmlHttp.onload = handler;
objXmlHttp.onerror = handler;
}
}
return objXmlHttp;
}
function GetMSXmlHttp()
{
var xmlHttp = null;
var clsids = [“Msxml2.XMLHTTP.6.0″,”Msxml2.XMLHTTP.5.0”,
“Msxml2.XMLHTTP.4.0″,”Msxml2.XMLHTTP.3.0”,
“Msxml2.XMLHTTP.2.6″,”Microsoft.XMLHTTP.1.0”,
“Microsoft.XMLHTTP.1″,”Microsoft.XMLHTTP”];
for(var i=0; i
Get Involved! AJAX — dispite its shortcomings is an awesome, fairly new technology that has great potential. Take a while and research it. Want tutorials?
http://www.google.com/search?hl=en&q=AJAX+Tutorials&btnG=Google+Search :
http://www.w3schools.com/ajax/default.asp
http://codinginparadise.org/projects/tutorials/
http://www.maxkiesler.com/index.php/weblog/comments/round_up_of_30_ajax_tutorials/
http://www.petefreitag.com/item/515.cfm