Ajax auto complete state and country name when user enter city name with codeigniter
<p><strong>HTML Form</strong></p>

<pre><code>&lt;form role="form" id="registration_form" method="POST"&gt;
    &lt;input type="text" name="location" id="location"&gt;
    &lt;button type="submit" name="submit"&gt;sign up&lt;/button&gt; 
&lt;/form&gt;
</code></pre>

<p><strong>AJAX</strong></p>

<pre><code>&lt;script &gt; 
    $(function(){
        $("#location").autocomplete({
            source: "&lt;?php echo SITE_ROOT;?&gt;xyz/signup/autocomplete" 
        });
    });
&lt;/script&gt;
</code></pre>

<p><strong>Controller</strong></p>

<pre><code>function autocomplete()
{
    if (isset($_GET['term'])){
        $city = strtolower($_GET['term']);
        $this-&gt;registration_model-&gt;get_location($city);
    }
}
</code></pre>

<p><strong>Model</strong></p>

<pre><code>function get_location($city)
{
    $this-&gt;db-&gt;select('name');
    $this-&gt;db-&gt;like('name', $city); 
    $this-&gt;db-&gt;limit('6'); 
    $query = $this-&gt;db-&gt;get('cities');

    if($query-&gt;num_rows() &gt; 0){

        foreach ($query-&gt;result_array() as $row){ 
            $row_set[] = htmlentities(stripslashes($row['name']));
        } 

        echo json_encode($row_set);  
    }
}
</code></pre>

<p>Problem:How can I display auto-complete state name and country name after city name when user can enter city name?
output of this code: 
if you type s in text box this code gives 6 names in which s latter is comes.</p>