You're probably having problems because the jQuery jQuery.getJSON() method uses a GET request (the clue's in the method name) to return JSON data to your javascript, not to POST JSON data to your back-end. For that, you'd want to use the more generic jQuery.ajax() method, kinda like this:
var postData['data[Model][field]'] = 'value'; $.ajax({ type: 'POST', dataType: 'json', url: '/locations/find', data: postData, success: function(result) { // do something with the result object } }); The data should be available in your controller as $this->data['Model'] ['field'] - it won't be JSON, as there's no need for it to be. The javascript will expect JSON data back though. David On Sep 22, 8:09 am, jkritikos <[EMAIL PROTECTED]> wrote: > I m not usind json_encode() - After all, I m able to get JSON data > from the controller to my view just fine. The problem is when I make a > JSON request from my view to the controller and pass some parameters. > It's those params that I cannot access.. > > On Sep 22, 3:14 am, Donkeybob <[EMAIL PROTECTED]> wrote: > > > What is your controller code? are you using json_encode in it? > > something like this ---> echo json_encode($this->Model- > > > >find('all')); > > > On Sep 21, 7:24 pm, jkritikos <[EMAIL PROTECTED]> wrote: > > > > Hi there, > > > > I'm having trouble accessingJSONdata from a controller. (I'm using > > > cake version 1.2). MyJSONrequest is as follows: > > > > $.getJSON( > > > '/locations/find', > > > {s1:val1, s2:val2}, > > > function callback(data){ > > > //doStuff > > > > }); > > > > I know that theJSONrequest is made just fine because when I tried it > > > with empty params I got the response OK. The trouble is that I get > > > errors if i try to access the data from the controller using: > > > > //$val = $this->params['val']; > > > > Do i need to decode theJSONstring? I've tried $this->params, $this->data > > > but none seem to do it as they are only used for http POST > > > > commands. Note that I m not using any ajax orjsonhelpers/components > > > etc. > > > > Thanks, > > > > jason --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---