Ver Mensaje Individual
  #1 (permalink)  
Antiguo 17/10/2012, 09:21
Avatar de satjaen
satjaen
 
Fecha de Ingreso: septiembre-2012
Ubicación: Jaén (Andalucía)
Mensajes: 893
Antigüedad: 11 años, 7 meses
Puntos: 10
Php para Autocompletar

Hola, me puede decir alguien por favor como construir el search.php para este autocompletado?

Código Javascript:
Ver original
  1. <!doctype html>
  2.  
  3. <html lang="en">
  4. <head>
  5.     <meta charset="utf-8" />
  6.     <title>jQuery UI Autocomplete - Remote with caching</title>
  7.     <link rel="stylesheet" href="http://code.jquery.com/ui/1.9.0/themes/base/jquery-ui.css" />
  8.     <script src="http://code.jquery.com/jquery-1.8.2.js"></script>
  9.     <script src="http://code.jquery.com/ui/1.9.0/jquery-ui.js"></script>
  10.     <link rel="stylesheet" href="/resources/demos/style.css" />
  11.     <style>
  12.     .ui-autocomplete-loading {
  13.         background: white url('images/ui-anim_basic_16x16.gif') right center no-repeat;
  14.     }
  15.     </style>
  16.     <script>
  17.     $(function() {
  18.         var cache = {};
  19.         $( "#birds" ).autocomplete({
  20.             minLength: 2,
  21.             source: function( request, response ) {
  22.                 var term = request.term;
  23.                 if ( term in cache ) {
  24.                     response( cache[ term ] );
  25.                     return;
  26.                 }
  27.  
  28.                 $.getJSON( "search.php", request, function( data, status, xhr ) {
  29.                     cache[ term ] = data;
  30.                     response( data );
  31.                 });
  32.             }
  33.         });
  34.     });
  35.     </script>
  36. </head>
  37. <body>
  38.  
  39. <div class="ui-widget">
  40.     <label for="birds">Birds: </label>
  41.     <input id="birds" />
  42. </div>
  43.  
  44.  
  45. </body>
  46. </html>

Gracias.