title: Convert old jquery auto complete with latest jquery autocomplete ui
body: <p>I have been trying to convert my autosuggest script from the jquery autocomplete 1.1 to the latest autocomplete ui but seems to be finding it difficult to do. would be glad if anyone could help.
  PHP code:</p>
  
  <pre><code>  include( "dbconnect.php" );
  $term = trim(strip_tags(strtolower($_GET['term'])));
  if ( !$term )
  {
  }
  else
  {
      $query = "SELECT DISTINCT city as cityname,id as cityid FROM city where LCASE(city) like '%".$term."%'";
      $results = mysql_query( $query );
  while ($row = mysql_fetch_array($results,MYSQL_ASSOC))
      {
      $row_set[]=(int)$row['cityid'];
      $row_set[]=htmlentities(stripslashes($row['cityname']));
  
      }
  
  }
  echo json_encode($row_set);//format the array into json data
  </code></pre>
  
  <p>and this:</p>
  
  <pre><code>include( "dbconnect.php" );
  $term = trim(strip_tags(strtolower($_GET['term'])));
  $city = intval( $_GET['city_val'] );
  
  if ( !$term )
  {
  }
  else
  {
      $query = "SELECT DISTINCT locality as localityname,id as localityid FROM locality where cityid='{$city}' and LCASE(locality) like '%".$term."%'";
      $results = mysql_query( $query );
      while ($row = mysql_fetch_array($results,MYSQL_ASSOC))
      {
  
      $row_set[]=htmlentities(stripslashes($row['localityname']));
      $row_set[]=(int)$row['localityid'];
  
  
      }
  
  }
  echo json_encode($row_set);//format the array into json data
  </code></pre>
  
  <p>and the js:</p>
  
  <pre><code>// Set default values to -1 and disable locality
      $("#city").focus();
      $("#city_val").val(-1);
      $("#locality").val("Select City First");
      $("#locality_val").val(-1);
      document.getElementById('locality').disabled =true;
  
  
  
      // start city part
  $( "#city" ).autocomplete({
    source: 'new_suggestion.php',
    minLength: 2,
  
  });
  
  $("#city").result(function(event,data,formatted)
  {
      //$("#city_val").val(data[1]);
  
      if ( document.getElementById('city').value == "" )
              {
              $("#city").val("National Search");
              $("#city_val").val(-1);
              $("#locality").val("Select City First");
              $("#locality_val").val(-1);
              document.getElementById('locality').disabled =true;
              var ct="-1";
              }
      else
              {
              $("#city_val").val(data[1]);
  
              document.getElementById('locality').disabled =false;
              $("#locality_val").val(-1);
              $("#locality").val("");
              var ct=data[1]
              }
  
  // if city value found start locality here
  if (ct != -1)
  {
  // locality starts //
  $("#locality").val("");
  $("#locality_val").val(-1);
  
  $( "#locality" ).autocomplete({
    source: "new_suggestion2.php?city_val="+ct,
    minLength: 2,
  });
  
  $("#locality").result(function(event, data, formatted)
      {
  
          if (document.getElementById('locality') == "" )
          {
          $("#locality_val").val(-1);
          $("#locality").val("true");
          }
          else
          {
          $("#locality_val").val(data[1]);
          }
      });
  // locality ends //
  } // end of if ct
  </code></pre>