
var xhr;
var targetDIV;

function ajaxPageCall(pageURL, pageDIV){
	
	targetDIV = pageDIV;
	
	if (window.XMLHttpRequest) {
		xhr = new XMLHttpRequest();
	}
	else {
		xhr = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	// document.getElementById('debug').innerHTML = p_url;
	xhr.open("GET", pageURL);
	
	try {
		xhr.onreadystatechange = ajaxReadyStateChange;			
		xhr.send(null);		//su questa istruzione, selezionando l'ultima voce
	}
	catch (err) {
		//alert("errore 1");
	}
}

function ajaxReadyStateChange() {
	if (xhr.readyState == 4) {
		if (xhr.status == 200 || xhr.status == 0) {
			//alert(xhr.responseText);
			testoHTML = xhr.responseText;
					
			//Update HTML into the DIV
			document.getElementById(targetDIV).innerHTML = testoHTML;		
		}
	}
}
