Foros del Web » Programando para Internet » Javascript » Frameworks JS »

problema con innerhtml ayuda!!

Estas en el tema de problema con innerhtml ayuda!! en el foro de Frameworks JS en Foros del Web. Hola foreros, tengo un pequeñito problema, con una función de innerHTML: Código: <script> /** * @author Jonathan Miguel Costas * @version 1.0 * @web http://www.jomico.com.ar ...
  #1 (permalink)  
Antiguo 18/06/2008, 08:30
Avatar de yrduk  
Fecha de Ingreso: enero-2007
Ubicación: Caracas, Venezuela
Mensajes: 277
Antigüedad: 17 años, 3 meses
Puntos: 3
Pregunta problema con innerhtml ayuda!!

Hola foreros, tengo un pequeñito problema, con una función de innerHTML:

Código:
<script>
	/**
 * @author Jonathan Miguel Costas
 * @version 1.0
 * @web http://www.jomico.com.ar
 * @param string [url]. String que representa una direccion http en la cual se envia la peticion.
 * @param json [advanced]. Objeto JSON con parametros para la completa configuracion del
 * 	envio/recepcion de una peticion.
 * Parametros admitidos:
 * method: string [metodo], metodo de envio, puede ser GET o POST
 * query: string [query], datos a enviar, formateados 'valor0=dato0&valor1=dato1'
 * header: string [header], valor de la cabecera Content-Type utilizada para realizar la peticion.
 * dataGet: boolean [dataGet], forma de procesar la respuesta, true es Texto false XML.
 * async: boolean [async], true si la peticion se envia de manera asincrona, false si es sincronica.
 * nocache: boolean [nocache], true para evitar el cacheo de la peticion, false en caso contrario.
 * timer: int [timer], cantidad de milisegundos que se establece como tiempo de espera en las peticiones.
 * success: object [funcion], funcion que se ejecuta una vez que termina la peticion.
 * error: object [funcion], funcion que se ejecuta en caso de error. Ejemplo error 404,etc.
 * exception: object [funcion], funcion que se ejecuta en caso de errores en tiempo de ejecucion.
 * wait: object [funcion], funcion que se ejecuta mientras transcurre la peticion.
 * 		Su uso principal es para crear un feedback mientras se espera que finalice la peticion.
 * endtimer: object [funcion], funcion que se ejecuta cuando finaliza el tiempo de espera (timer).
 */

//Create Object
Ajaxsa = function(param0, param1){//Metodo de peticion y Object JSON
	this.http= "";
	this.url = param0;
	this.json = param1;
	this.dheader = "application/x-www-form-urlencoded";
	//Security
	if(this.url){
		(this.json!=undefined)?this.advanced():this.basic();
	}else{
		alert("No ha ingresado parametros para funcionamiento correcto");
	}
}
var data = "";var idtimer=0;
//Prototipado
Ajaxsa.prototype = {
	instance:function(){
		try{
			this.http = new XMLHttpRequest();
		}catch(e){
			try{
				this.http = new ActiveXObject('Msxml2.XMLHTTP');
			}catch(e){
				try{
					this.http = new ActiveXObject("Microsoft.XMLHTTP"); 
				}catch(e){
					return false;
				}
			}
		}
		return true;
	},
	advanced:function(){//Modo Avanzado
		data = {
			method:this.json.method?this.json.method:"get",
			query:(this.json.method.toLowerCase()=="post")?"?":"?"+this.json.query,
			body:this.json.query,
			header:this.json.header?this.json.header:this.dheader,
			dataGet:this.json.dataGet!=undefined?this.json.dataGet:true,
			async:this.json.async!=undefined?this.json.async:true,
			nocache:this.json.nocache!=undefined?this.json.nocache:false,
			timer:this.json.timer?this.json.timer:0,
			success:this.json.success?this.json.success:function(){return arguments[0];},
			error:this.json.error?this.json.error:function(){return 0;},
			exception:this.json.exception?this.json.exception:function(){return 0;},
			wait:this.json.wait?this.json.wait:function(){return 0;},
			endTimer:this.json.endTimer?this.json.endTimer:function(){return 0;}
		};
		//Funcion Lanzadora
		this.main();
	},
	basic:function(){//Modo Basico
		//Configuracion
		data = {method:"GET",query:"",body:null,
			header:this.dheader,dataGet:true,
			async:true,nocache:false,timer:0,
			success:function(item){return 0;},
			error:function(){alert("Direccion URL no existe.");},
			exception:function(){alert("Error en ejecucion");},
			wait:function(){return 0;},endTimer:function(){return 0;}
		};
		//Funcion Lanzadora
		this.main();
	},
	sender:function() {
		var myRand;
		//Genera numero aleatorio para evitar cacheo
		myRand = this.noCache();
		//Envia variables
		this.http.open(data.method,this.url+ data.query + myRand,data.async);
		this.http.setRequestHeader('Content-Type',data.header);
		this.http.send(data.body);
		//Timer
		if (data.timer) {
			idtimer = setTimeout(this.finalTimer, data.timer);
		}
	},
	noCache:function(){//Funcion NoCache
		var cache = data.nocache?"&rand="+parseInt(Math.random()*99999999):"";
		return cache;
	},
	main:function(){
		//instancia del objeto XMLHTTPRequest
		var bool = this.instance();
		if(bool){
			data.http = this.http;
			this.http.onreadystatechange = this.readystate;
			//Sender
			this.sender();
		}else{data.exception();}
	},
	readystate:function() {
		if(data.http.readyState == 4) {
				if(data.http.status == 200) {
					//Elimino Timer
					(data.timer)?clearTimeout(idtimer):"";
  				data.success(data.dataGet?data.http.responseText:data.http.responseXML);
  				}else if (data.http.status == 404){
					data.error();
				}
		}else {
			data.wait();
		}
		
	},
	onSuccess:function(nfunction){
		if(typeof nfunction == "function"){
			data.success = nfunction;
		}
	},
	finalTimer:function(){//Cancela Peticion
		data.http.abort();
		data.endTimer();
	}
};


function hecho(data){
document.getElementById("contenido_voto").innerHTML=data;
}
function esperando(){
document.getElementById("contenido_voto").innerHTML = "<center><br><img src=\"cargando.gif\"><br>Cargando retos...</center>";
}

function Votar(capa,url) {
var json={method:"GET",query:"&id=1",dataGet:true,async:true,
nocache:true,success:hecho,wait:esperando};var ajax=new Ajaxsa(url,json);
}
</script>
Más que un problema, es algo que quiero hacer y no puedo :S... Quiero que en la funcion Votar(); también se llame a un archivo para la capa "contenido" (osea que carguen dos archivos diferentes, en la capa contenido_voto (el que estoy recogiendo por el parámetro url) y otro que sería "GetVersus.php" en la capa "contenido" ... Pero no lo he podido hacer, no tengo conocimientos de AJAX, y estoy intentándolo desde ayer anoche :(

Si alguien me ayuda estaría muy agradecido de verdad! Saludos!
__________________
Twitter/kudry
mkd.la - blog
  #2 (permalink)  
Antiguo 18/06/2008, 11:25
Avatar de yrduk  
Fecha de Ingreso: enero-2007
Ubicación: Caracas, Venezuela
Mensajes: 277
Antigüedad: 17 años, 3 meses
Puntos: 3
Respuesta: problema con innerhtml ayuda!!

alguien que me ayude porfavor es urgente!!
__________________
Twitter/kudry
mkd.la - blog
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 13:16.