title: Jquery UI autocomplete ajax is not populating dropdown box
body: <p>I need help with this, I can't see where is the problem.</p>
  
  <p>When I set source for autocomplete in html file, it works fine, when I same source or database values print out in ajax.php and return it via ajax it doesn't work. What could be the problem? Help please.</p>
  
  <p>Html : </p>
  
  <pre><code>    &lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
          &lt;title&gt;Auto complete&lt;/title&gt;
          &lt;script type="text/javascript" src="jquery-1.7.1.min.js"&gt;&lt;/script&gt;
          &lt;script type="text/javascript" src="jquery-ui-1.8.18.custom.min.js"&gt;&lt;/script&gt;
          &lt;link rel="stylesheet" media="all" type="text/css" href="jquery-ui-1.8.custom.css" /&gt;
          &lt;style type="text/css"&gt;
              .ui-autocomplete-loading {
                  background: url("images/loader.gif") no-repeat scroll right center white;
              }
          &lt;/style&gt;
          &lt;script type="text/javascript"&gt;
              jQuery(document).ready(function($){                       
                  $("#ac").autocomplete({
                      minLength: 2,
                      //source: [{"value":"Some Name","id":1},{"value":"Some Othername","id":2}]
                      source: function( request, response){
                          $.ajax({
                              type: 'GET',
                              url: 'ajax.php',
                              data: {
                                  'term':request.term
                              },
                              contentType: "application/json; charset=utf-8",
                              dataType: "json",
                              success: function(data){
                                  console.log('Success : ' + data);
                              },
                              error: function(message){
                                  alert(message);
                              }
                          });
                      },
                      select: function( event, ui ) {
                      }
                  });
              });
          &lt;/script&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;input type="text" id="ac" name="ac" size="100" /&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>and my ajax.php file:</p>
  
  <pre><code>$dbhost = 'localhost';
  $dbuser = 'root';
  $dbpass = '';
  $dbname = 'test_db';
  
  $server = mysql_connect($dbhost, $dbuser, $dbpass);
  $connection = mysql_select_db($dbname, $server);
  
  $term = $_GET['term'];
  
  $qstring = "SELECT user_id,tName FROM `csv_data` WHERE tName LIKE '%" . $term . "%'";
  $result = mysql_query($qstring);
  
  $return_arr = array();
  
  $i = 0;
  while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {//loop through the retrieved values
      $row_a = array();
      if ($row['tName'] != null) {
          $i++;
          $row_a['value'] = ($row['tName']);
          $row_a['id'] = (int) $i;
          array_push($return_arr, $row_a);
      }
  }
  
  mysql_close($server);
  
  header("Content-type: text/x-json");
  
  /*$my_arr = array(
      array("value" =&gt; "Some Name", "id" =&gt; 1),
      array("value" =&gt; "Some Othername", "id" =&gt; 2)
  );*/
  
  //echo json_encode($return_arr);
  print json_encode($return_arr);
  
  //print json_encode($my_arr);
  </code></pre>
  
  <p>This is response from firebug(generated from database).</p>
  
  <pre><code>[{"value":"4 erste Spiele","id":1},{"value":"Meine ersten Spiele \"Blinde Kuh\"","id":2},{"value":"4 erste Spiele","id":3},{"value":"Meine ersten Spiele \"Blinde Kuh\"","id":4},{"value":"4 erste Spiele","id":5},{"value":"Meine ersten Spiele \"Blinde Kuh\"","id":6},{"value":"Maxi Kleine Spielewelt","id":7}]
  </code></pre>