title: Codeigniter ajax send data to controller using ajax code
body: <pre><code>&lt;script type="text/javascript"&gt;
      $(document).ready(function () {
          $("#select-dept").change(function () {
              var id = $("#select-dept").val();
              $.ajax({
                  type: "POST",
                  url: "&lt;?=base_url()?&gt;.index.php/sms/get_dept_employee",
                  //url: baseurl + 'sms/get_dept_employee',
                  data: "id",
                  dataType = "json",
                  cache: "false",
                  success: function (emp_list) {
                      $("#dept-emp").html(emp_list);
                  }
              });
          });
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>I am unable to send view data to controller function
  In view their is select box with departmenr values from mysql database</p>
  
  <pre><code>&lt;select class="select-dept" id="select-dept" name="select-dept"&gt;
      &lt;option&gt;Select Department&lt;/option&gt;
      &lt;?foreach ($departments as $dt):?&gt;
          &lt;option value="&lt;?=$dt['id']?&gt;"&gt;
              &lt;?=$dt[ 'name']?&gt;
          &lt;/option&gt;
      &lt;?endforeach;?&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>i need to get refresh when user select department and that need to call controller function
  <strong>get_dept_employee</strong>
  And need to display datagrid of employee list</p>