﻿

function createXMLHttpRequest() {
  if(window.XMLHttpRequest) {
    try { 
      xmlHttpRequest = new XMLHttpRequest();
    } catch(e) { return null; }
  } else if(window.ActiveXObject) {
    try {
      xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
    } catch(e) {
      try {
        xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) { return null; }
    }
  } else return null;
  return xmlHttpRequest;
}

function loadHTML(page, destination) {
	xhr = createXMLHttpRequest();
	if( xmlHttpRequest  == null) alert("No XMLHttpRequest available");
	
	

	xhr.onreadystatechange = function(){
		if(xhr.readyState == 4){
				paginaCaricata = xhr.responseText;
				div = document.getElementById(destination);
				div.innerHTML = paginaCaricata;
		}
	}
				
				// Make the call
	try {
	xhr.open("GET", page, true);
	} catch(e){ alert ("Load Error");}
	  try {
    // Send the Method Data
    xhr.send(null);
  } catch(e) { alert("Send  failed"); }
								
	
	return true;
}

