title: Jquery Ajax success function never called
body: <p>I have the following Ajax call:</p>
  
  <pre><code>    $.ajax({
      type: 'POST',
      url: myBaseUrl + 'Products/addItemToBasket',
      dataType: 'json',
      data: {
          id: window.location.pathname.substring(window.location.pathname.lastIndexOf('/') + 1),
          amount: amount
      },
      success: function (data) {
          alert(data);
          var dat = JSON.parse(data);
         }
      }
  });
  </code></pre>
  
  <p>Now this calls the following method in php:</p>
  
  <pre><code>    public function addItemToBasket()
  {
      if ($this-&gt;request-&gt;is('post')) {
          //todo delete efter at have insat fancybox med valg af antal styk. (sendes via ajax).
              $shopping = null;
              $item = $this-&gt;Product-&gt;find('first',array('conditions' =&gt; array('Product.id' =&gt;$this-&gt;request-&gt;data['id'])));
          if(isset($_SESSION['basket'])){
              $shopping =  $_SESSION['basket'];
          }else{
              $shopping = array();
          }
          array_push($shopping,$item);
          $_SESSION['basket'] = $shopping;
          echo json_encode($_SESSION['basket']);
      }
  }
  </code></pre>
  
  <p>When i try to debug it everything is working (it gets into the php function) and updates my <code>$_SESSION</code> variable.</p>
  
  <p>BUT it never runs the success function and it never alerts the data.</p>
  
  <p>What am i doing wrong?</p>