title: Display data through ajax using codeigniter
body: <p>I am new in ajax .did not able to understand how I get my required output. 
  I implement the dependent drop down. the problem is that when I chosed area from dropdown than I am not able to display the restaurant of that area. please tell me how I get the restaurant view.</p>
  
  <p>It's my view code</p>
  
  <pre><code>&lt;div class="container"id restaurant&gt;
  
  
          &lt;table align="centre" class="table table-condensed table-striped table-hover no-margin"style="width:70%"&gt;
              &lt;thread&gt;
                  &lt;tr style="width: 56%;"&gt;
                      &lt;th&gt;
                          No.
                      &lt;/th&gt;
                      &lt;th style=""&gt;
                          Restaurant Names
                      &lt;/th&gt;
                  &lt;/tr&gt;
              &lt;/thread&gt;
              &lt;tbody&gt;
              &lt;?php $i=1;foreach($result as $row){
                  ?&gt;
                  &lt;tr id="&lt;?php echo $row-&gt;restaurant_id; ?&gt;" class="res_id"&gt;
                      &lt;th style=""&gt;
                          &lt;?php echo  $i++; ?&gt;
  
                      &lt;/th&gt;
                      &lt;th style=""&gt;
                          &lt;?php echo $row-&gt;restaurant_name; ?&gt;
  
                      &lt;/th&gt;
                      &lt;th style="width: 1%" &gt;
                          &lt;a href="&lt;?php echo base_url();?&gt;index.php/BulkRecipe_Controller/bulk_recipe/&lt;?php echo $row-&gt;restaurant_id;?&gt;"  class="btn btn-warning" &lt;i class="glyphicon-edit"&gt;&lt;/i&gt;See Menu&lt;/a&gt;
                      &lt;/th&gt;
                  &lt;/tr&gt;
              &lt;?php } ?&gt;
              &lt;/tbody&gt;
          &lt;/table&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>its my controler code</p>
  
  <pre><code>     public function get_rests()
      {
  
          $cit_id = $this-&gt;input-&gt;post('cit_id');
          $area = $this-&gt;input-&gt;post('areaID');
          $where = array('city_id'=&gt;$cit_id,'city_area_id'=&gt;$area);
  
          $data = $this-&gt;bulk-&gt;select_record('restaurant',$where);
          echo $data = json_encode($data);
  }
  </code></pre>
  
  <p>Its script code</p>
  
  <pre><code>function get_rests(){
  
          var city_id = $('#city_id').val();
          var area_id = $("#area_id").val();
          $.ajax({
              type: "POST",
              url: "&lt;?=base_url();?&gt;index.php/Bulk_Controller/get_rests",
              data: {cit_id: city_id,areaID: area_id},
              dataType: "text",
              cache:false,
              success:
                  function(data){
                      $('#restaurant').html(data);
                  }
          });
      }
  </code></pre>
  
  <p>Its model code</p>
  
  <pre><code>function select_record($table, $where = NULL){
  
      $this-&gt;db-&gt;select();
      if($where)
          $this-&gt;db-&gt;where($where);
      $this-&gt;db-&gt;from($table);
      $query = $this-&gt;db-&gt;get();
      return $query-&gt;result();
  }
  </code></pre>
  
  <p>Its front end view after select the area</p>
  
  <p><a href="https://i.stack.imgur.com/9ze1p.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9ze1p.png" alt="enter image description here"></a></p>