title: Populating dropdown using ajax php codeigniter
body: <p>I have been trying all the help available on different forums but now give up and posting my question here. Trying to populate dropdown using ajax call. Getting the data in json format successfully. But don't know to fill dropdown. code below:
  Controller:</p>
  
  <pre><code>function getRegion()
  {
      $this-&gt;load-&gt;model('Settings_model');
      $title = $this-&gt;input-&gt;get('title');
  
      $result =   array("region" =&gt; $this-&gt;Settings_model-&gt;getSelectedRegion($title));
      echo json_encode($result);      
  }
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>        $(document).on('change', '#campaignSel', function() {
          changecampaign();
      });
  
      function changecampaign(){
          var title= "New Normal";//$('#campaignSel option:selected').text();//$('#campaignSel').text();
          $regionSel = $("#regionSel");
              $.ajax({
                  type:"GET",
                  url: "&lt;?php echo base_url('Pricecomparison/getRegion'); ?&gt;",
                  data:{ "title":"New Normal"},
                  datatype: "json",
                  success: function(result){
                      var appenddata;
                      $.each(result, function (key, value) {
                          appenddata += "&lt;option value = '" + value.id + " '&gt;" + value.region + " &lt;/option&gt;";                        
                      });
                      $('#regionSel').html(appenddata);
                  },
                  error: function(xhr, textStatus, error){
                      console.log(xhr.statusText);
                      console.log(textStatus);
                      console.log(error);
                  }
              });
          }
  </code></pre>
  
  <p>Response: {"region":[{"id":"1","region":"109 FEATHERSTON ST (ELEC)\r\n"},{"id":"2","region":"ASHBURTON/MID CANTERBURY
   ELEC"}]}
  I want to fill dropdown with Regions.</p>