title: call controller from javascript on view using codeigniter
body: <p>hey guys i am facing trouble in calling controller method from javascript pls help . .</p>
  
  <p>my view is</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      function kccbranchselect()
      {
          $.ajax({
          type : 'POST',
          data : 'addreceiptkccbranchid='+ $('#addreceiptkccbranch').val(),
          url : '&lt;?php echo base_url();?&gt;index.php/ctl_dbcont/getmembersbybranch',
          success :   function(data){
                          $('#addreceiptddsmember').val(data);
                      }
          });
      }
  &lt;/script&gt;
  &lt;select id="addreceiptkccbranch" name="addreceiptkccbranch" onChange="kccbranchselect();" tabindex="1" &gt;
      &lt;option value=""&gt;--SELECT--&lt;/option&gt;
      &lt;?php foreach($branchlist as $value):?&gt;
          &lt;option value="&lt;?=$value['branch_id']?&gt;"&gt;&lt;?=$value['branch_name']?&gt;&lt;/option&gt;
      &lt;?php endforeach; ?&gt;
  &lt;/select&gt;
  &lt;select id="addreceiptddsmember" name="addreceiptddsmember" tabindex="1"&gt;
      &lt;?php foreach($member_by_branch as $row) { ?&gt;
          &lt;option value = ""&gt;&lt;/option&gt;
      &lt;?php } ?&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>my controller is</p>
  
  <pre><code>function getmembersbybranch()
  {
      $this-&gt;load-&gt;model('mod_user');
      $addreceiptkccbranchid      =   $_POST['addreceiptkccbranchid'];
      $data['member_by_branch']   =   $this-&gt;mod_user-&gt;member_receipt_dds($addreceiptkccbranchid);
      redirect('view_addreceipts');
  }
  </code></pre>
  
  <p>i am generating a dropdown by selecting another dropdown option . . i cant access the controller method by putting <code>url : '&lt;?php echo base_url();?&gt;index.php/ctl_dbcont/getmembersbybranch',</code> in ajax ,why ??</p>