ajax复选框没有将我的数据传递给codeigniter中的控制器

I'm trying to update my database data using checked box with ajax. the checkbox is running when I clicked it alert the success msg. but not passing the data to my controller. I don't know where to find my mistake here. I'm trying to figure out how to check if the data is pass to my controller.

Anyone can help me?

view

$checked = FALSE;
if($result->consignment == 1) { $checked = TRUE; }
    $data = array(
        'value'   => $result->id, 
        'onClick' => 'incoming_CheckboxState();',
        'class'   => 'incoming',
        'checked' => $checked
    );
echo form_checkbox($data);?> Incoming

ajax

function incoming_CheckboxState() {
  if ($('.incoming').is(':checked')) {

    var id = $('.incoming').val();
    var yes = 1;                
    $.ajax({
        type: "POST",
        url: "<?=based_url(); ?>user_accounts/update_permission",
        data: { user_id : id, status : yes },
        success: function(msg) {
            alert("Activated");
        }
    });
  } 
}

controller

public function update_permission(){
    $data = array(
       'id' => $this->input->post('user_id'),
        'status' => $this->input->post('status')
    );
    $this->user_accounts_model->incoming($data);
}

model

public function incoming($data){
    $this->db->set('consignment', $data['status'])
             ->where('id', $data['id'])
             ->update('users');
}

Do these

  1. Change AJAX URL

    url: "<?=base_url()?>user_accounts/update_permission"
    
  2. Set your base_url.(application/config/config.php)

    $config['base_url'] = 'http://stackoverflow.com/';
    
url: "<?=based_url()?>./user_accounts/update_permission",

Should be (Your base url in config.php should be set with a trailing slash):

url: "<?= base_url(); ?>user_accounts/update_permission",

Where are you getting that . from?

Open your inspector, go to network and click on XHR to monitor ajax requests being made (so you can see if the request is made and if your post data is there as well).