如何将数据数组从控制器传递到定义的js变量中的视图?

时间:2016-06-02 21:27:02

标签: javascript php codeigniter

如何将$data array ['1']从控制器传递到定义的js变量serial=$(this).val();中的视图?

在Controller ::

public function add_video() {
  $query = "SELECT * FROM `video_category`";
  $query1 = "SELECT * FROM `video_sub_category`";            
  $data['1'] = $this->madmin->avideo_category($query);
  $data['2'] = $this->madmin->avideo_sub_category($query1);             
  $this->view_page->admin_page('v_add_video', $data);           
}

在View ::

$(document).ready(function(){
    $("#change_category").change(function(){
        serial=$(this).val();// $data['1'] will be added here
    })
    $("#change_sub_category").change(function(){
        serial=$(this).val();// $data['2'] will be added here
    })        
})

0 个答案:

没有答案