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

Busqueda tipo Google Suggestion

Estas en el tema de Busqueda tipo Google Suggestion en el foro de Frameworks JS en Foros del Web. Ey.. estoy intentando hacer una busqueda tipo google suggestion.. a traves de un ejemplo que lei.. pero aun no me funcione... este funciona cuando el ...
  #1 (permalink)  
Antiguo 16/04/2006, 23:10
Avatar de B**
B**
 
Fecha de Ingreso: enero-2006
Ubicación: Monterrey,Mexico
Mensajes: 952
Antigüedad: 18 años, 3 meses
Puntos: 3
Busqueda tipo Google Suggestion

Ey.. estoy intentando hacer una busqueda tipo google suggestion.. a traves de un ejemplo que lei.. pero aun no me funcione... este funciona cuando el usuario pone algo en la caja de texto, luego con keyup.. mandara una consulta a googl y a traves de php, recibira los resultados en un arreglo.. pero justo cuando escribo algo y le doy el keyup, sale error de javascript.. creo q el error esta en la funcion q se activa cuando tecleo keyup..pero no encontre algun errror..
el codigo es el siguiente..
Código PHP:
<html>
<
head>
<
title>Google live search</title>
<
style>
#targetDiv {
background-color#FFEEAA;
width30%;
}
</
style>

<
script languaje="javascript">
    var 
Ajax=false;
    if(
window.xmlhttpRequest){
      
Ajax=new XmlhttpRequest();
    }
    else if (
window.ActiveXObject){
      
Ajax=new ActiveXObject("Microsoft.Xmlhttp2");

    }

    function 
getData(datasource){
        if(
Ajax){
          
Ajax.open("GET",datasource);
          
Ajax.onreadystatechange = function(){
            if(
Ajax.readystate == && Ajax.status == 200){
               eval(
Ajax.responsetext);
             }
          }
           
    
Ajax.send(null);
  }
}

    
function 
getSuggest(keyEvent){
  
keyEvent= (keyEvent) ? keyEvent:window.event;
  
input =(keyEvent.target) ? keyEvent.target:keyEvent.srcElement;
    if(
keyEvent.type == "keyup"){
      if(
input.value){
        
getData("google.php?qu=" input.value);

      }
      else{
        var 
targetDiv document.getElementById("targetDiv");
        
targetDiv.innerhtml "<div> </div>";

      }
    }

}

    function 
sendRPCDone(unusedVariablesearchTermarrayTerm,arrayResultsunusedArray)
    {
        var 
data="<table>";
        var 
loopindex;
        if(
arrayResults.length != 0){
          for(var 
loopindexloopindex arrayResults.lengthloopindex++){
            
data+= "<tr> <td>" "<a href='http://www.google.com/search?q=" +
arrayTerm[loopindex] + "'>" arrayTerm[loopindex] +
'</a></td><td>' arrayResults[loopindex] + "</td></tr>";
          }

        }
        
data += "</table>";
        var 
targetDiv =document.getElementbyid('targetDiv');
        
targetDiv.innerhtml data;

  }
</script>
</head>
<body>


<H1>Google live search</H1>
    Search for <input id = "textField" type = "text"
    name = "textField" onkeyup = "getSuggest(event)">

    <div id = "targetDiv"><div></div></div>


</body> 
y el php es el siguiente:

Código PHP:
<?php
        $handle 
fopen("http://www.google.com/complete/search?hl=en&js=true&qu=" .
        
$_GET["qu"], "r");

       while (!
feof($handle)){
            
$text fgets($handle);
            echo 
$text;
        }

       
fclose($handle);
?>
Gracias de antemano
  #2 (permalink)  
Antiguo 21/04/2006, 20:46
 
Fecha de Ingreso: noviembre-2002
Ubicación: Mex
Mensajes: 140
Antigüedad: 21 años, 5 meses
Puntos: 0
¿Quieres un ejemplo más fácil?
ve a:
http://www.fuenteria.com/?external=55

Saludos
__________________
escribiendo mi libro de AJAX
  #3 (permalink)  
Antiguo 12/05/2006, 03:08
perrogrun
Invitado
 
Mensajes: n/a
Puntos:
Akí teneis otro ejemplo http://www.forosdelweb.com/f127/clone-google-suggest-392120/
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 08:08.