title: cannot POST using AJAX in Codeigniter
body: <p>Hoping I have maybe overlooked something here. I have been looking for a bit and cannot find a solution. </p>
  
  <p>In CI, I am trying to POST via AJAX in an onClick event. when triggered, the event should add an item to the shopping cart. </p>
  
  <p>My Javascript is as follows:</p>
  
  <pre><code>function addToCart(id) {
  
      var productID = id;
      var qty = 1;
  
  
      $.ajax({
          url : "/menu/add/"
          type : "POST",
          dataType : "json",
          data : {"productid" : productID, "qty" : qty},
          success : function(data) {
              alert(data);
          },
          error : function(data) {
              alert(data);
          }
      });
  }
  </code></pre>
  
  <p>Inside my Menu controller, the add function reads as follows:</p>
  
  <pre><code>public function add(){
      if (isset($_POST['productid']) &amp;&amp; 
          isset($_POST['qty'])       &amp;&amp;
          is_numeric($_POST['qty'])  &amp;&amp;
          $this-&gt;product_model-&gt;isValidProductId($_POST['productid']) 
          ){
              $productData = array(
                 'product_id'   =&gt; $_POST['productid'],
                 'product_qty'  =&gt; $_POST['qty']
              );
  
              $cart_array = $this-&gt;session-&gt;userdata('cart');
  
              array_push($cart_array, $productData);
              $this-&gt;session-&gt;set_userdata('cart', $cart_array);
          }
  }
  </code></pre>
  
  <p>I call the function like this:</p>
  
  <pre><code>&lt;h1 onclick="addToCart(23)"&gt;OTown Cafe Menu- Click an item to add it to your order!&lt;/h1&gt;
  </code></pre>
  
  <p>Neither the success or error is triggered from ajax, however if I put an alert before or after the ajax it IS triggered. Anyone seeing what I've done wrong?</p>