title: How to use autocomplete using JQuery from database with codeigniter?
body: <p>this is my search type with this following code: </p>
  
  <pre><code>&lt;input type="text" required ="required"name="city_code" id="code" autocomplete="off" class="form-control"&gt;
  </code></pre>
  
  <p>and this is my jquery what i have tried to done :</p>
  
  <pre><code>function city_value()
  {
      return '/ajax/get_address_list?city_code='+$('#code').val();
  }
  
  $tmp_location={};
  
  $('#code').autocomplete({
      serviceUrl:city_value,
      minChars:2,
      lookupLimit: 25,
      focus_suggestion:true,
      transformResult: function(response) {
          $tmp_location=$.parseJSON(response);
          return {
              suggestions: $tmp_location
          };
      }
  });
  </code></pre>
  
  <p>and this is my controller for the search autocomplete type :</p>
  
  <pre><code>function get_address_list(){
      $post_code= $this-&gt;input-&gt;get("city_code",true);
      $location_list=$this-&gt;ajax_m-&gt;m_get_address_like($post_code);
      echo json_encode($location_list);
  }
  </code></pre>
  
  <p>here is the model :</p>
  
  <pre><code>function m_get_address_like($city_code){
      $sql = "SELECT `singapore_address`,`singapore_postal_code`
              FROM `uhd_singapore_address`
              WHERE `singapore_postal_code`='$city_code%' OR (singapore_address LIKE '$city_code%')";
      $query=$this-&gt;db-&gt;query($sql);
      return $query-&gt;result_array();
  }
  </code></pre>
  
  <p>i have checked using firebug there is and i got this following error in my autocomplete.js </p>
  
  <pre><code>Autocomplete.formatResult = function (suggestion, currentValue) {
      var pattern = '(' + utils.escapeRegExChars(currentValue) + ')';
  
      return suggestion.value.replace(new RegExp(pattern, 'gi'), '&lt;strong&gt;$1&lt;\/strong&gt;');// in this line
  };
  </code></pre>