嘿伙计们,我在从 javascript 调用控制器方法时遇到了麻烦,请帮助。.
我的看法是
<script type="text/javascript">
function kccbranchselect()
{
$.ajax({
type : 'POST',
data : 'addreceiptkccbranchid='+ $('#addreceiptkccbranch').val(),
url : '<?php echo base_url();?>index.php/ctl_dbcont/getmembersbybranch',
success : function(data){
$('#addreceiptddsmember').val(data);
}
});
}
</script>
<select id="addreceiptkccbranch" name="addreceiptkccbranch" onChange="kccbranchselect();" tabindex="1" >
<option value="">--SELECT--</option>
<?php foreach($branchlist as $value):?>
<option value="<?=$value['branch_id']?>"><?=$value['branch_name']?></option>
<?php endforeach; ?>
</select>
<select id="addreceiptddsmember" name="addreceiptddsmember" tabindex="1">
<?php foreach($member_by_branch as $row) { ?>
<option value = ""></option>
<?php } ?>
</select>
我的控制器是
function getmembersbybranch()
{
$this->load->model('mod_user');
$addreceiptkccbranchid = $_POST['addreceiptkccbranchid'];
$data['member_by_branch'] = $this->mod_user->member_receipt_dds($addreceiptkccbranchid);
redirect('view_addreceipts');
}
我通过选择另一个下拉选项来生成一个下拉列表。. 我无法通过放入url : '<?php echo base_url();?>index.php/ctl_dbcont/getmembersbybranch',
ajax 来访问控制器方法,为什么?