Autocomplete problem

Autocomplete problem

Hello.
I'm trying to create autocomplete using jquery ui with php but it's not working.
I don't know what I'm doing wrong.

index.php

  1.  <p><label>Team host:</label><input type='text' name='team_host' value="" class='auto'></p>


ajax.js

  1. $(function() {
  2.    
  3.     //autocomplete
  4.     $(".auto").autocomplete({
  5.         source: "search.php",
  6.         minLength: 1
  7.     });               
  8. });


search.php


  1. <?php
     require_once 'dao/TeamHostDAO.php';
     
    require_once 'includes/Connection.php';
    $teamhostdao = new TeamHostDAO();

    $keyword=isset($_GET['team_host']) ?isset($_GET['team_host']):'null';

    if($keyword){
         $teamHosts = $teamhostdao->selectByKeyword($keyword);
    }
function select by keyword in TeamHostDAO

  1.   public function selectByKeyword($keyword){
  2.         $result=array();
  3.         try {
  4.             $sql="SELECT team_host FROM teams_host WHERE team_host LIKE :team_host";
  5.             $stmt=  $this->connection->prepare($sql);
  6.             $stmt->bindValue(':team_host','%'.$keyword.'%',  PDO::PARAM_STR);
  7.            
  8.             $stmt->execute();
  9.            
  10.            
  11.             while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
  12.                 //echo $row['email']."  ";
  13.                 $result[]=$row;
  14.             }
  15.            // return $result;
  16.         } catch (Exception $exc) {
  17.             echo $exc->getTraceAsString();
  18.             echo $exc->getMessage();
  19.         }
  20.            echo json_encode($result);
  21.     }