Ver Mensaje Individual
  #2 (permalink)  
Antiguo 15/06/2008, 16:23
Avatar de yrduk
yrduk
 
Fecha de Ingreso: enero-2007
Ubicación: Caracas, Venezuela
Mensajes: 277
Antigüedad: 17 años, 3 meses
Puntos: 3
Respuesta: Un problema con include

Hola, puedes usar javascript y la funcion innerhtml... yo uso ésta función:

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();
	}
};
document.write('<span id="content"></span>');

function ver_retos() {var json={method:"GET",query:"&id=1",dataGet:true,async:true,
nocache:true,success:hecho,wait:esperando};var ajax=new Ajaxsa("http://www.benitosfera.es/sidben.php",json);
}

ver_retos();

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

Espero que te sirva! Saludos...
__________________
Twitter/kudry
mkd.la - blog