title: ajax is not working in codeigniter view
body: <p>i'm working with CodeIgniter, and i'm trying to send form data to a controller with AJAX.
  The problem is that when i try to get the datas in the controller by using $this->input->get_post("sku_qty"), the content of it is NULL. ajax is also getting error.
   here's the code:</p>
  
  <p>container_view_2.php</p>
  
  <pre><code>    &lt;?php
      /*
       * To change this license header, choose License Headers in Project Properties.
       * To change this template file, choose Tools | Templates
       * and open the template in the editor.
       */
      ?&gt;
      &lt;html&gt;
  &lt;head&gt;
  
    &lt;link href="&lt;?php echo base_url('assets/css/bootstrap.min.css'); ?&gt;" rel="stylesheet" type="text/css" /&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
    &lt;div class="container"&gt;
      &lt;div class="col-sm-12 text-primary"&gt;
        &lt;center&gt;
          &lt;h2&gt;Container calculator&lt;/h2&gt;
        &lt;/center&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="container"&gt;
      &lt;form method="post" action=""&gt;
        &lt;div class="col-sm-8 col-md-8 col-lg-8 col-xs-12 col-md-offset-2 col-lg-offset-2  col-sm-offset-2"&gt;
          &lt;div class="col-sm-12 form-group"&gt;
            &lt;label&gt;Partner Name&lt;/label&gt;
            &lt;select id="partners" name="partnername" class="form-control selectpicker"&gt;
                                      &lt;option value="Amazon"&gt;Amazon.com&lt;/option&gt;
                                      &lt;option value="Homedepot"&gt;Homedepot.com&lt;/option&gt;
                                      &lt;option value="Build"&gt;Build.com&lt;/option&gt;
                                  &lt;/select&gt;
          &lt;/div&gt;
  
  
        &lt;/div&gt;
        &lt;div class="col-sm-8 col-md-8 col-lg-8 col-xs-12 col-md-offset-2 col-lg-offset-2  col-sm-offset-2"&gt;
          &lt;div class="col-sm-6 col-lg-6 col-md-6 col-xs-12 form-group"&gt;
            &lt;label&gt;SKU&lt;/label&gt;
            &lt;select id="sku" name="sku" class="form-control selectpicker"&gt;
                                      &lt;option value="Build"&gt;Build&lt;/option&gt;
                                      &lt;option value="Homedepot"&gt;Homedepot&lt;/option&gt;
                                      &lt;option value="Amazon"&gt;Amazon&lt;/option&gt;
                                  &lt;/select&gt;
          &lt;/div&gt;
          &lt;div class="col-sm-6 col-lg-6 col-md-6 col-xs-12 form-group"&gt;
            &lt;label&gt;Qty&lt;/label&gt;
            &lt;input type="number" name="sku_qty" id="sku_qty" placeholder="Enter the qty" class="form-control"&gt;
          &lt;/div&gt;
          &lt;div class="col-sm-6 col-lg-6 col-md-6 col-xs-12 form-group"&gt;
            &lt;label&gt;Start Port Name&lt;/label&gt;
            &lt;input type="text" name="spname" id="spname" placeholder="start port name" class="form-control"&gt;
          &lt;/div&gt;
          &lt;div class="col-sm-6 col-lg-6 col-md-6 col-xs-12 form-group"&gt;
            &lt;label&gt;End Port Name&lt;/label&gt;
            &lt;input type="text" name="epname" id="epname" placeholder="end port name" class="form-control"&gt;
          &lt;/div&gt;
          &lt;div class="col-sm-6 col-lg-6 col-md-6 col-md-offset-7  col-lg-offset-7 col-sm-offset-7 form-group"&gt;
            &lt;div class="col-sm-3 col-md-3 col-lg-3 col-md-offset-1 col-lg-offset-1 col-sm-offset-1"&gt;&lt;button type="submit" onclick="calculateContainerdata()" class="btn btn-primary"&gt;CALCULATE&lt;/button&gt;&lt;/div&gt;
            &lt;div class="col-sm-3 col-md-3 col-lg-3 col-md-offset-2 col-lg-offset-2 col-sm-offset-2"&gt;&lt;/div&gt;
  
          &lt;/div&gt;
        &lt;/div&gt;
  
      &lt;/form&gt;
  
    &lt;/div&gt;
    &lt;div class="container" style="margin-top: 1em"&gt;
      &lt;div class="col-sm-6"&gt;
        &lt;div class="panel panel-info"&gt;
          &lt;div class="panel-heading"&gt;Nested Box Container&lt;/div&gt;
          &lt;div class="panel-body"&gt;
  
            &lt;?php
                                  //echo $partners;
                                  ?&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="col-sm-6"&gt;
        &lt;div class="panel panel-info"&gt;
          &lt;div class="panel-heading"&gt;Boxed Container Info&lt;/div&gt;
          &lt;div class="panel-body"&gt;
            &lt;table class="table table-responsive text-center"&gt;
              &lt;thead&gt;
                &lt;tr&gt;
                  &lt;th scope="col"&gt;Container Size&lt;/th&gt;
                  &lt;th scope="col"&gt;SKU Qty&lt;/th&gt;
                  &lt;th scope="col"&gt;Cost&lt;/th&gt;
                  &lt;th scope="col"&gt;container qty&lt;/th&gt;
                &lt;/tr&gt;
              &lt;/thead&gt;
              &lt;tbody&gt;
                &lt;tr&gt;
                  &lt;td&gt;40"&lt;/td&gt;
                  &lt;td&gt;500&lt;/td&gt;
                  &lt;td&gt;1500&lt;/td&gt;
                  &lt;td&gt;1&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td&gt;20"&lt;/td&gt;
                  &lt;td&gt;500&lt;/td&gt;
                  &lt;td&gt;1600&lt;/td&gt;
                  &lt;td&gt;2&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td&gt;18"&lt;/td&gt;
                  &lt;td&gt;500&lt;/td&gt;
                  &lt;td&gt;1800&lt;/td&gt;
                  &lt;td&gt;3&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td&gt;10"&lt;/td&gt;
                  &lt;td&gt;500&lt;/td&gt;
                  &lt;td&gt;1900&lt;/td&gt;
                  &lt;td&gt;5&lt;/td&gt;
                &lt;/tr&gt;
  
              &lt;/tbody&gt;
            &lt;/table&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  
    &lt;script type="text/javascript" src="&lt;?php echo base_url('assets/js/bootstrap.min.js'); ?&gt;"&gt;&lt;/script&gt;
    &lt;script type="text/javascript" src="&lt;?php echo base_url('assets/js/jquery-1.10.2.min.js'); ?&gt;"&gt;&lt;/script&gt;
    &lt;script&gt;
      function calculateContainerdata() {
  
        var partners = $('#partners :selected').val();
        var sku = $('#sku :selected').val();
        var sku_qty = $('#sku_qty').val();
        var spname = $('#spname').val();
        var epname = $('#epname').val();
        alert(partners);
        var url = "&lt;?php echo site_url('container/calcajax'); ?&gt;";
        alert(url);
        $.ajax({
          url: url,
          data: {
            partners: partners,
            sku: sku,
            sku_qty: sku_qty,
            spname: spname,
            epname: epname,
            url: url
          },
          dataType: "json",
          type: "POST",
          success: function(rdata) {
            alert(rdata);
            //window.location.href = '&lt;?php //echo site_url("index");  ?&gt;';
          },
          error: function(xhr, status, error) {
            alert("error" + xhr.responseText);
          }
        });
      }
    &lt;/script&gt;
  
  
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>my controller is :
     Container.php</p>
  
  <pre><code>        &lt;?php
      defined('BASEPATH') OR exit('No direct script access allowed');
      /* 
       * container calculator view
       * To change this template file, choose Tools | Templates
       * and open the template in the editor.
       */
      class Container extends CI_Controller {
  
          public function __construct() {
              parent::__construct();  
              $this-&gt;load-&gt;helper('url');
          }
  
          public function index() {
  
  
              $this-&gt;load-&gt;view('container_view_2');
             // $this-&gt;load-&gt;view('container_view');
  
              //echo 'pramod';
          }
  
          public function calcajax() {
              $partners = $this-&gt;input-&gt;post('sku_qty');
               echo json_encode($partners);
              exit();
  
  
          }
  
      }
  </code></pre>