Just add a div under the input tag

HTML Code:

<input type="text" id="city" name="city" autocomplete="off"/> 
<div id="key"></div>

replace the div after the success on you ajax.

Ajax Code:

     var ajaxurl="<?php echo admin_url( 'admin-ajax.php' ); ?>"; 
     var data ={ action: "city_action",  city:cid    };
        $.post(ajaxurl, data, function (response){
                     $('#key').html(response);
           });

PHP Code:

       function city_action_callback() {     
       global $wpdb;
            $city=$_GET['city'];
            $result =   $mytables=$wpdb->get_results("select * from ".$wpdb->prefix . "mycity where city like '%".$city."'" );   
            $data = "";
            echo '<ul>'
            foreach($result as $dis)
            {
                         echo '<li>'.$dis->city.'</li>';
            }
            echo '</ul>'    
         die();
       }

Have any doubt, then comment here!

Leave a Reply

Your email address will not be published. Required fields are marked *