如何在codeigniter中将参数从javascript传递给控制器​​?

I want pass parameter from javascript to codeigniter controller. How to do this. My javascript file is like below

user.js

function confirmcourse(){  
     $('.confirm').unbind("click");
     $('.confirm').on("click",function(e){
         var courseId=$(this).attr('data-id');
         $.ajax({
            type: "POST",
            data:{cid: courseId},
            url: urljs+"user/Teach_controller/confirmcourse",
            dataType:'json',
        }).done(function( data ) {
            if(data.result=1){
                window.location.assign(urljs+"user/Learn_controller");
            }else{
                noty({ text: 'Something went wrong during process please try again',type: 'error',modal:true,timeout:1000});
                window.location.reload();
            }
        });
    });
}

Learn_controller

public function index($course_type ==''){
        $id=$this->session->userdata('cp_userid');
        $userdetails=$this->Usermodel->getuserdetails($id);
        $data['userdetails']=$userdetails;
        $result=$this->Usermodel->currentlearningcourses($id);
        $data['details']=$result;
        $data['content']=$this->load->view("user/currentlearningcourses",$data,true);

        if($course_type == 'teaching'){
            $result = $this->Usermodel->teachingcourses($id);
            $data['details'] = $result;
            $data['content'] = $this->load->view("user/teachingcourses",$data,true);
        }

        $data['title']='My Courses';            
        $headerContent = $this->load->view("user/layout",$data,true);
        $this->render($headerContent);
    }

I want to take that teaching parameter to index of Learn_controller from the javascript file.

You should read it in controller with $_POST['cid']

But controller response of an ajax call can't be a view is a good practice that it be a JSON

$this->output->set_content_type('application/json');
$this->output->set_output(json_encode($data));

in your case with $data['result'] = 1;