JavaRSS, an aggregation site, has published an article called "AJAX in Action," showing how AJAX is being used on the site to display summaries of items based on mouseover, rather than including the summaries in the home page. Benefits for JavaRSS included a front page that was much smaller and, thus, much faster on initial load.
The heart of the AJAX functionality is in this code, which talks to a custom JSP page on JavaRSS to retrieve the description:
function getDescription(channelId,itemId) {
var url = 'http://localhost:8080/getDescription.jsp?channelId=' + channelId + '&itemId=' + itemId;
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
}
req.onreadystatechange = processRequest;
req.open("GET", url, true);
req.send(null);
}
function processRequest() {
if (req.readyState == 4) {
if (req.status == 200) {
parseMessages();
} else {
alert ( "Not able to retrieve description" );
}
}
}
function parseMessages() {
response = req.responseXML.documentElement;
itemDescription = response.getElementsByTagName('description')[0].firstChild.data;
alert ( itemDescription );
}
There has been a large amount of AJAX-related content on the Internet lately. Is AJAX poised to revolutionize the web user interface? Also, JavaRSS uses a setting to enable AJAX in the user interface. How are you handling cases where the browser might not be able to handle AJAX? What about accessibility? Has anyone worked out how to handle blind users' interactions with AJAX?