function getXmlHttp(){
	var xmlhttp
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e1) {
      			xmlhttp = false;
		}
	}
	
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
	}

	return xmlhttp;
}

function example1() {
	var req = getXmlHttp()
	req.open('GET', '/xhr/test.php', false)
	req.send(null)
	if(req.status == 200) {
		alert(req.responseText)
	}
}

function example2() {
	var req = getXmlHttp()
	req.open('GET', '/xhr/test.php', true)
	req.onreadystatechange = function() {
		if (req.readyState == 4) {
			if(req.status == 200) {
				alert(req.responseText)
			}
		}
	}
	req.send(null) 
}

