Ver Mensaje Individual
  #18 (permalink)  
Antiguo 10/02/2008, 06:23
Avatar de jerkan
jerkan
 
Fecha de Ingreso: septiembre-2005
Mensajes: 1.607
Antigüedad: 18 años, 7 meses
Puntos: 19
Re: Peticiones simultaneas

Yo he intentado aplicar lo de los arrays pero no me funciona. Si wakewakeup pudiera colgar el código completo sería de gran ayuda.

Yo tengo implementada una clase para hacer las peticiones AJAX. Es por ello que no entiendo por qué no funciona simplemente al hacer oAjax = new CAjax(...) y oAjax2 = new CAjax(...).
¿No debería crear una instancia diferente de todos y cada uno de sus atributos (incluido el xmlhttp)?
Código:
function sendRequest() 
{
	_http = this.http;
	_capa = this.capa;
	
	// efecto actualizando
	document.getElementById(_capa).innerHTML = this.processing_message;

		
	// Open PHP script for requests
	_http.open('post', this.accion + "?datehack=" + new Date().getTime(), true);
	_http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	_http.onreadystatechange = function() {
			
		if( _http.readyState == 4 )
		{ 
			if( _http.status == 200 )
			{
				// Text returned FROM the PHP script
				var response = _http.responseText;
				
				if(response) 
				{
				 // UPDATE ajaxTest content
				 document.getElementById(_capa).innerHTML = response;
				}
			}
			else
			{
				document.getElementById(_capa).innerHTML = "Error: " + _http.status;
			}
		}
  	}

   _http.send(this.variables);

}


function CAjax(accion, variables, capa, processing_message)
{
	// atributos
	
		this.http = createRequestObject();
		this.accion = accion;
		this.variables = variables;
		this.capa = capa;
		this.processing_message = processing_message;
	
	
	// metodos
	
		this.procesa = sendRequest;
}
(La función createRequestObject es la típica para obtener un objeto xmlhttp).

¿Alguna ayuda?