title: Manage AJAX request data in a CakePHP controller
body: <p>I'm trying to access an AJAX request's data from a CakePHP controller, but failing to understand where is the form's data once I'm in the controller.</p>
  
  <p>Inside my view, between form tags, I have the following code:</p>
  
  <pre><code>echo $this-&gt;Js-&gt;submit(
      'Proceed',
      array(
      'url' =&gt; array(
          'controller' =&gt; 'json',
          'action' =&gt; 'itemSelection'
      ),
      'dataType' =&gt; 'json',
      'id' =&gt; 'proceed',
      'success' =&gt; 'onSuccessFunct( data )'
  ));
  </code></pre>
  
  <p>This results i the following code:</p>
  
  <pre><code>$(document).ready(function (){
      $("#proceed").bind("click", function(event){
          $.ajax({
              data:$("#proceed").closest("form").serialize(),
              dataType: "json",
              success:function (data, textStatus) {
                  onSuccessFunct( data )
              },
              type:"post",
              url:"\/koro\/json\/itemSelection"
          });
          return false;
      });
  });
  </code></pre>
  
  <p>This part seems to be working fine, the request is done on click, the success function is called, the problem is that I'm not understanding how to treat the form's data in the controller.</p>
  
  <p><code>$this-&gt;request-&gt;data</code> appears empty, and I'm not understanding where's the form data going to. If I'm not greatly misunderstanding JQuery, it should be parsed in a querystring manner, <a href="http://api.jquery.com/serialize/" rel="nofollow">as shown in the <code>.serialize()</code> demo</a>, but again, I'm failing to understand where is the serialized data stored once it's in the controller.</p>
  
  <p>The code for the controller is just a loop through a table's rows, comparing form data with table data, and storing that in another variable which is then returned as JSON. An <code>if($this-&gt;request-&gt;is('ajax'))</code> is called before proceeding to the function's code, inside which there's the aforementioned loop, where there used to be an if which tested the form data to check that it's value was different to null and 0. I don't believe the controller code is really an issue.</p>
  
  <p>To summarize:</p>
  
  <ul>
  <li>Is there a default variable where CakePHP stores data from an AJAX request's serialized form?</li>
  <li>If not, where is this data stored in regular AJAX requests || how can I redirect it to a variable of my choosing? (Sorry for this AJAX noob follow-up)</li>
  </ul>
  
  <p>Needless to say, any comment/answer is welcome, thanks in advance</p>
  
  <p>PD: The code was tested and worked fine when it was in it's pre-AJAX state (I was treating everything through post requests). In favor of order and usability I started migrating it to AJAX just yesterday.</p>