Clean AJAX Implementation, Simply Clean !
Clean AJAX is an open source engine for Asynchronous JavaScript with XML that, in few words, is a technology that can be used to perform asynchronous HTTP requests programatically. The main purposes of this project are:
- Provide an AJAX engine that could be used to improve web applications and make then even better;
- Provide an AJAX engine easy to use, easy to integrate with any project and self contained (that doesn't require anything else to work);
- Popularize Rich Internet Applications based on open standards (What the Web should be!).
A Simple usage of Clean AJAX :
/**
* Perform AJAX HTTP get
*/
function ajax_get(url, elementId, win){
message = new Message();
message.method = "GET";
message.address = url;
message.document = win.document;
message.consumer = elementId;
message.onError = showError;
wait(elementId, win.document);
Connection.sendMessage(message);
}
/**
* Show AJAX error messages
*/
function showError(e){
alert(e);
}
/**
* Apply HTML code on destination element to show response's progress
*/
var waitImage = new Image();
waitImage.src = "";
function wait(elementId, doc){
di = new DomIterator(doc);
html = "<center><img src='" + waitimage.src + "'/></center>";
di.applyValue(elementId, html);
}

Leave a comment »