Ver Mensaje Individual
  #6 (permalink)  
Antiguo 11/12/2009, 07:09
Avatar de jackson666
jackson666
 
Fecha de Ingreso: noviembre-2009
Ubicación: Buenos Aires, Argentina
Mensajes: 1.971
Antigüedad: 15 años, 4 meses
Puntos: 65
Respuesta: comprobar disponibilidad de un nick

Para llamar a esta funcion, pones un boton con un evento onclick="startAjax()" (un boton comun, no nu submit). O un link
Código HTML:
<script language="javascript">
var xhr=false;
function startAjax(){
    if(window.XMLHttpRequest){
        xhr=new XMLHttpRequest();
    }else{
        try{
            xhr=new ActiveXObject("Microsoft.XMLHTTP");
        }catch(e){
            try{
                xhr=new new ActiveXObject('Msxml2.XMLHTTP');
            }catch(e){}
        }
    }
    if(xhr!==false){
        var nick=document.getElementById("idDeTuInput").value;
        xhr.open("GET","tuArchivo.php?v="+nick);
        xhr.onreadystatechange=function(){
            if(xhr.readyState==4){
                if(xhr.status==200){
                    var resp=xhr.responseText;
                        if(resp=="ok"){
                            //le das el ok
                        }else{
                            //esta ocupado el nick
                        }
                }
                
            }
        }
    }
    
}
</script> 
Despues en tu archivo php bajkas la variable con $_GET['v']; y ahces la consulta a la base de datos