 
			
				22/09/2008, 15:14
			
			
			     |  
      |    |    |    Fecha de Ingreso: septiembre-2008  
						Mensajes: 65
					  Antigüedad: 17 años, 1 mes Puntos: 2     |        |  
  |      Respuesta: Problema una vez enviado un formulario con AJAX        Con esta primera funcion recupero los datos para enviarlos por POST 
function getRecuestFields(oForm) 
{ 
	var aParams = new Array();   
	for (var i=0 ; i < oForm.elements.length; i++) 
	{ 
		var sParam = encodeURIComponent(oForm.elements[i].name); 
		sParam += "="; 
		sParam += encodeURIComponent(oForm.elements[i].value); 
		aParams.push(sParam); 
	}   
	return aParams.join("&"); 
	aParams = ''; 
}     
Con esta segunda mando los datos a la pagina php que hace el update en la base de datos.   
function update_datos(elForm) 
{ 
	var oForm = elForm;   
	var sBody = getRecuestFields(oForm);   
	var oXmlHttp = zXmlHttp.createRequest(); 
	var accion = oForm.action; 
	accion = accion + '&nocache=' + Math.random();   
	oXmlHttp.open("post", accion, true); 
	oXmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");   
	oXmlHttp.onreadystatechange = function() 
	{ 
		if(oXmlHttp.readyState == 4) 
		{ 
			if(oXmlHttp.status == 200) 
			{ 
				var arr_respuesta = oXmlHttp.responseText.split("||");   
				if(!eval(arr_respuesta[0])) 
				{ 
					MuestraInformacion(arr_respuesta[1]); 
				} 
				else 
				{ 
					return false; 
				} 
			} 
			else 
			{ 
				MuestraInformacion("A ocurrido un error al intentar Actualizar los datos: " + oXmlHttp.statusText); 
			} 
		} 
	}; 
	oXmlHttp.send(sBody); 
}           |