Ver Mensaje Individual
  #8 (permalink)  
Antiguo 30/05/2009, 08:22
Avatar de abimaelrc
abimaelrc
Colaborador
 
Fecha de Ingreso: mayo-2009
Ubicación: En el planeta de Puerto Rico
Mensajes: 14.734
Antigüedad: 15 años
Puntos: 1517
Respuesta: validar campo con datos de Base de datos

Bueno con ajax trata de hacerlo de esta forma. Por lo general con este codigo lo que tu modificas son variables y tal vez alguno que otro campo. Vas a ver que se te va a ser bien facil

Código PHP:
var xmlHttp;
function 
showPoll(VARIABLE){
    
xmlHttp=GetXmlHttpObject();
    if (
xmlHttp==null){
        
alert ("Tu navegador no soporta AJAX! No podras usar esta aplicación.");
        return;
    }

    var 
url="PAGINA_QUE_VAS_A_HACER_CONSULTA.php";
    
url=url+"?VARIABLE="+VARIABLE;


    
//Puedes crear una variable en la funcion que diga cual es el id que deseas verificar tu escoges
    
document.getElementById("DIV_ID").innerHTML="";
    
xmlHttp.onreadystatechange=function(){
        if (
xmlHttp.readyState==1){
        
img document.createElement('img');
        
img.src="images/ajaxLoading.gif";
        
document.getElementById("DIV_ID").appendChild(img);
        
document.getElementById("DIV_ID").appendChild(document.createTextNode(" Cargando por favor espere..."));
        }
        if (
xmlHttp.readyState==4){
            
document.getElementById("DIV_ID").innerHTML=xmlHttp.responseText;
        }
    }
    
xmlHttp.open("GET",url,true);
    
xmlHttp.send(null);
}

function 
GetXmlHttpObject(){
    var 
xmlHttp=null;
    try{
        
// Firefox, Opera 8.0+, Safari
        
xmlHttp=new XMLHttpRequest();
    }catch(
e){
        
// Internet Explorer
        
try{
            
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }catch(
e){
            try{
                
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
            }catch(
e){}
        }
    }
    return 
xmlHttp;


Parece complicado pero intentalo. Solo tienes que asegurarte que todo este bien en el archivo de PHP

Última edición por abimaelrc; 05/06/2009 a las 07:44