0
已经我的控制器索引方法加载一个参数,其中两个下拉字段,当我选择第一个然后我得到第二个与jquery ajax数据,然后当我选择第二个,然后我需要从list_ByBatch方法传递另一个数组。codigniter:如何传递数组从控制器查看与jquery
我的控制器:
public function index() {
$data['round'] = $this -> AttendanceModel -> get_round();
$this->load->view('common/header');
$this->load->view('common/menu');
$this->load->view('attendance/attendance', $data);
$this->load->view('common/footer');
}
public function list_ByBatch(){
$batch=$this->input->post('batchid',TRUE);
$list['trainee']=$this->AttendanceModel->get_traineeList($batch);
if(!empty($list['trainee'])){
return $list['trainee'];
}
}
脚本:
<script type="text/javascript">
$(document).ready(function() {
$("#round").change(function(){
/*dropdown post */
$.ajax({
url:"<?php echo base_url(); ?>index.php/attendance/batch_ByRound",
data: {round: $(this).val()},
type: "POST",
success: function(data){
$("#batch-list").html(data);
}
});
});
$("#batch-list").change(function(){
/*dropdown post */
$.ajax({
url:"<?php echo base_url(); ?>index.php/attendance/list_ByBatch",
data: {batchid: $(this).val()},
type: "POST",
success: function(data){
$("#traineeList").html(data);
$("#subTotal").html("Total: " + $('#traineeList tr').length.toString());
document.getElementById("classHour").defaultValue = "4";
}
});
});
});
</script>
我如何通过在“list_ByBatch”查看时#批处理列表改变功能执行其已经加载页面的阵列。
很大,得到了它。但是如何在查看页面中接收这个数组? –
它是您的ajax调用中成功回调的第一个参数。 – taxicala
可以请你帮忙做到这一点。我如何在我的视图页面中获取变量。 –