I got it figured out....something simple. json_encode($response); exit(); Added exit(); after the response was sent back. This gave me a clean JSON response with my view wrapped inside the JSON
Thanks to those who helped along the way. Dave -----Original Message----- From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On Behalf Of John Andersen Sent: January-11-10 3:36 PM To: CakePHP Subject: Re: Please help..stuck and no luck Ok, got it :) So now you have the response with the view included, when the result is a success! You have to look into how you process a JSON response in javascript! Googling, I found this, which may help you on the way: http://www.dynamicajax.com/fr/JSON_AJAX_Web_Chat-271_290_324.html Look at the section named "The client side JSON", which is the processing of the JSON response in the browser. Enjoy, John On Jan 11, 8:58 pm, "Dave" <make.cake.b...@gmail.com> wrote: > Ok I tried a few things. > > My response is: > > {"data":{"title":"","year_rec":{"year":"2010"},"description":"","id":" > 9aaf36 272a1","profile_id":"2608"},"html":"<p>this is a good > test<\/p>\r\n"}<p>this is a good test</p> > > With in the controller: > $response['data'] = $this->data['Award']; $response['html'] = > $this->render('dummy'); > > $this->header('Content-Type: application/json'); echo > json_encode($response); > > But the html is slashed up \r\n/ > > Or this: > > $response['data'] = $this->data['Award']; $this->render('dummy'); > > $this->header('Content-Type: application/json'); echo > json_encode($response); > > Returns this response: > {"data":{"title":"","year_rec":{"year":"2010"},"description":"","id":" > 0e46a3 > 6212a","profile_id":"4b40eea7-2608-4a3b-9c24-7cb04adcd75b"}}<p>this is > a good test</p> > > With the html outside of the $response > > I am new to the idea of JSON so im not sure what it should look like. > > Ideas > > Thanks > > Dave > > -----Original Message----- > From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On > Behalf > > Of John Andersen > Sent: January-11-10 3:06 PM > To: CakePHP > Subject: Re: Please help..stuck and no luck > > This was my answer :) > > [answer] > Now, if I understand it correctly, and I don't have Ajax running yet > on my site, then you just need to use the controllers method - render > ( view name > ) and save the result in your responce variable. > [/answer] > > Enjoy, > John > > On Jan 11, 8:28 pm, "Dave" <make.cake.b...@gmail.com> wrote: > > Sorry I do not see an answer. > > > I never got one...will check the Google board. For some reason my > > emails from the cake group are sparatic...don't seem to be getting > > all of them for some reason. > > > Dave > > [snip] > > No virus found in this incoming message. > Checked by AVG -www.avg.com > Version: 9.0.725 / Virus Database: 270.14.130/2607 - Release Date: > 01/11/10 04:05:00 No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.725 / Virus Database: 270.14.130/2607 - Release Date: 01/11/10 04:05:00
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en