title: Passing data to a CakePHP controller using jQuery's $.post()
body: <p>If I'm sending data from an anchor attribute:</p>
  
  <pre><code>&lt;a id="123"&gt;foo&lt;/a&gt;
  </code></pre>
  
  <p>With no <code>&lt;form&gt;</code> around it,</p>
  
  <p>Using jquery's $.post() to one of my controllers:</p>
  
  <pre><code>    $('.add-fav').click(function() {
      var id = $(this).attr('id');
      $.post('/ajax/addFavorite', function(data){
      id : id
      }, 'json');
  });
  </code></pre>
  
  <p>How can I retrieve the data within that controller? I'm not using a model to validate anything, so using Cake's built-in formhelper convention shouldn't matter.</p>
  
  <pre><code>     public function addFavorite() {
         $this-&gt;autoRender = false;
  
         $bar = $_POST['id'] // normally I'd do this to get '123' from the anchor id, but it doesn't work since it wasn't submitted within a form
  
          $dataBack = json_encode($bar);
  
         if($this-&gt;RequestHandler-&gt;isAjax()) {
              if($this-&gt;Session-&gt;read('Auth.User')) {
                  return $dataBack;
              }
         }
   }
  </code></pre>
  
  <p>I can send a json_encoded associative array as data back to $.post(), but I can't seem to send what was originally sent back (e.g. id which goes through the controller and sending it back). Am I missing something fundamental here or is it not possible to do without sending the data in an input field (hidden maybe) inside of a <code>&lt;form&gt;</code>?</p>