function CreateXHR() {
	var retval = false;
	
	if (window.XMLHttpRequest && typeof XMLHttpRequest != 'undefined') {
		try {
			retval = new XMLHttpRequest();
		} catch (e) {
			retval = false;
		}
	} else if (window.ActiveXObject) {
		try {
			retval = new ActiveXObject('Msxml2.XMLHTTP');
		} catch (e) {
			try {
				retval = new ActiveXObject('Microsoft.XMLHTTP');
			} catch (e2) {
				retval = false;
			}
		}
	}
	return retval;
}

function RequestData(p_request, p_URL, p_data, p_func, p_method) {
	if (p_request) {
		p_request.onreadystatechange = p_func;
		if (p_method == 'GET') {
			p_request.open('GET', p_URL + '?' + p_data, true);
			p_request.send(null);
		} else {
			p_request.open('POST', p_URL, true);
			p_request.send(p_data);
		}
	}
}

function ParseResponse() {
	if (request.readyState == 4) {
		if (request.status == 200) {
			var response = request.responseText;
			
			alert(response);
		} else {
			alert('There was a problem retrieving the data: \n' + request.statusText);
		}
		request = null;
	}
}

var request;

window.onload = function() {
	request = CreateXHR();
	RequestData2(request, 'response.php', null, ParseResponse, 'POST');
}

Interactive Applications for the Web

Ajax: The Definitive Guide

By: Anthony T. Holdener III
Publisher: O'Reilly Media, Inc. (January 25, 2008)
Paperback: 957 pages
ISBN: 0-596-52838-8 (978-0-596-52838-6)

Welcome

Welcome to the supplementary site for O'Reilly Media, Inc.'s Ajax: The Definitive Guide by Anthony T. Holdener III.

The pinwheel menu to the left will take you to the various parts of the site (click the image to open the wheel). Currently available is a page with all of the examples from the book (I am working on getting the unnumbered ones out here as well), a page listing any errata for the book, a page with a brief "about me", and a page with media reviews and reader ratings.

Please contact me with any problems, and I hope you find the site useful.