jquery - Manage AJAX request data in a CakePHP controller -


i'm trying access ajax request's data cakephp controller, failing understand form's data once i'm in controller.

inside view, between form tags, have following code:

echo $this->js->submit(     'proceed',     array(     'url' => array(         'controller' => 'json',         'action' => 'itemselection'     ),     'datatype' => 'json',     'id' => 'proceed',     'success' => 'onsuccessfunct( data )' )); 

this results following 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;     }); }); 

this part seems working fine, request done on click, success function called, problem i'm not understanding how treat form's data in controller.

$this->request->data appears empty, , i'm not understanding where's form data going to. if i'm not misunderstanding jquery, should parsed in querystring manner, as shown in .serialize() demo, again, i'm failing understand serialized data stored once it's in controller.

the code controller loop through table's rows, comparing form data table data, , storing in variable returned json. if($this->request->is('ajax')) called before proceeding function's code, inside there's aforementioned loop, there used if tested form data check it's value different null , 0. don't believe controller code issue.

to summarize:

  • is there default variable cakephp stores data ajax request's serialized form?
  • if not, data stored in regular ajax requests || how can redirect variable of choosing? (sorry ajax noob follow-up)

needless say, comment/answer welcome, in advance

pd: code tested , worked fine when in it's pre-ajax state (i treating through post requests). in favor of order , usability started migrating ajax yesterday.

if data being sent query string, going $this->params->query instead of $this->request->data. if that's not is, try debug($this->request); , debug($this->params);


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -