leggendo i link che ha postato gentilmente fcaldera ho potuto riscrivere la classe con il formalismo corretto (anche quello che avevo usato prima doveva esserlo secondo un tutorial ma vedo che questo funziona meglio).
adesso riesco ad istanziare l'oggetto ma poi qualcosa si blocca ugualmente...
e credo sia un problema dovuto ad ajax... evidentemente con il formalismo object oriented devo gestire la cosa in maniera diversa ma non so come.
in particolare l'esecuzione si blocca nel metodo receiveResponse().
qui ho messo degli alert per seguire l'andamento del flusso esecutivo e ho potuto vedere che il problema è dato dal fatto che non si riesce ad entrare nel primo ramo IF.
cosa che prima ha sempre funzionato (il codice è sempre lo stesso ho cambiato solo il formalismo). in particolare la faccenda riguarda l'oggetto XMLHttpRequest che istanzio nel metodo requestPage() e salvo nella proprietà della classe ajax che ho chiamato objSOCK.
secondo il tutorial che ho seguito questa proprietà dovrebbe essere accessibile da tutti i metodi della classe... eppure a questo punto la proprietà "readyState" dell'oggetto objSOCK ritorna 0 come se non fosse mai stato istanziato....
in relatàl'oggetto è stato instanziato e la proprietà dovrfebbe ritornare 4....
non capisco... qualche anima pia può darci un occhiata pls?
grazie mille
ecco il codice
codice:
function ajax(){
	this.objSOCK = null;

	this.openSock = function(){
		var xmlhttp ;
		try{
		    xmlhttp = new XMLHttpRequest(); // Gecko (Firefox, Moz), KHTML (Konqueror, Safari), Opera, Internet Explorer 7
		}catch(e){
		    var MSXML_XMLHTTP_PROGIDS = new Array(
		        'MSXML2.XMLHTTP.5.0',  
		        'MSXML2.XMLHTTP.4.0',
		        'MSXML2.XMLHTTP.3.0',
		        'MSXML2.XMLHTTP',      // Internet Explorer 6
		        'Microsoft.XMLHTTP'   // Internet Explorer 4,5
		    );
		    var success=false;
		    for(var i=0;i < MSXML_XMLHTTP_PROGIDS.length && !success; i++){
		        try{
		            xmlhttp = new ActiveXObject(MSXML_XMLHTTP_PROGIDS[i]);
		            success=true;	
		        }catch(e){}
		    }
		    if(!success)
		        alert('attenzione: per navigare questo sito e necessario abilitare javascript o activeX');
		}
		return xmlhttp;
	}
	
	
	this.printOut = function(target, html){
	   document.getElementById(target).innerHTML = html
	}
	
	
	this.receiveResponse = function(target) {
		alert('ok1');		
		if(this.objSOCK.readyState == 4) { 	
		alert('ok2');						
			if (this.objSOCK.status == 200 || this.objSOCK.statusText=="Found") {							
				this.printOut(target, this.objSOCK.responseText);    
			}else{
				this.printOut(target, "error:\n"+this.objSOCK.statusText);
			}
		}
		alert('ok3');
	}
	
	
	this.requestPage = function(url, target, method, parameters) {
		this.objSOCK=this.openSock(); // creo l'oggetto XMLHttpRequest
		if(this.objSOCK){					
			//this.objSOCK.onreadystatechange=function(){this.receiveResponse(target);};
			this.objSOCK.onreadystatechange=this.receiveResponse(target);						
			if(method == undefined){method="GET";}
			this.objSOCK.open(method, url, true);					
			if (method == "GET" || method == "get"){			
				//setTimeout('this.objSOCK.send("")',1000);
				this.objSOCK.send("");					
			}else{
				this.objSOCK.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				this.objSOCK.setRequestHeader('Content-length', parameters.length);
				this.objSOCK.setRequestHeader('Connection', 'close');
				//setTimeout('this.objSOCK.send(parameters)',1000);
				this.objSOCK.send(parameters);
			}
		}
	}	
	
	
	this.sendForm = function(url, target, method, form_id){		
		var form = document.getElementById(form_id);
		var parametri = "";	
		// gestione di radio button e checkbox
		var name = new Array(); 
		var value = new Array();	
		var k=0;
		for(var i=0; i<form.elements.length; i++){		
			if((form.elements[i].type == "radio" || form.elements[i].type == "checkbox") && form.elements[i].checked){ 
				name[k] = form.elements[i].name;
				value[k] = form.elements[i].value; 
				k++; 
			}
		}	
		for(var i=0; i<value.length; i++) {
			parametri += name[i] + "=" + value[i] + "&";
		}				
		// gestione dei campi text e simili
		for(var i=0; i<form.elements.length; i++){		
			if(form.elements[i].type!="radio" && form.elements[i].type!="checkbox"){
				parametri += form.elements[i].name + "=" + form.elements[i].value + "&";
			}
		}				
		// invio dei parametri al server
		if(method == "GET" || method=="get" || method==undefined) 
			this.requestPage(url+"?"+parametri, target, method); 
		else if(method == "POST" || method=="post") 
			this.requestPage(url, target, method, parametri); 
	}
}
// -------------------------------------------------------------------------------------------------


	function request(url, target, title){				
		if(title!="")
			document.getElementById('imgTitle').src='img/titoli/'+title+'.jpg';
		var objAJAX = new ajax();
		objAJAX.printOut(target, "<div align='center'>[img]img/loading.gif[/img]</div>"); // preload
		objAJAX.requestPage(url,target);
	}
	
	
	function send(url, target, title, method, formId){
		if(title!="")
			document.getElementById('imgTitle').src='img/titoli/'+title+'.jpg';
		var objAJAX = new ajax();
		objAJAX.printOut(target, "<div align='center'>[img]img/loading.gif[/img]</div>"); // preload
		objAJX.sendForm(url, target, method, formId);
	}