I did this <a href="http://www.pagebakers.nl/2007/06/05/using-json-in- cakephp-12/"Using JSON in CakePHP 1.2> tutorial from the Pagebakers blog to get JSON working with my installation of CakePHP.
Almost everything seems to be working fine. When I go to http://localhost/mkb/index I get the page like normal and when I go to index.json I get a download dialog. I'm getting my JSON headers when I make a call with JQuery as well so it seems to be sending the JSON right. The problem is when I tried to get content with the JSON. I can't get it to give me any content, only the headers. Here's my javascript: $(document).ready(function() { $('.post').click(function(event) { event.preventDefault(); var postId = $(this).children('.id').text(); var postUrl = 'posts/view/post.json?='+postId+''; //inject a DIV container after the clicked title $(this).append('<div class="postContent post'+postId+'"></div>'); $.getJSON(postUrl, function(data) { $('div[class="postContent post'+postId+'"]').append(data); }); //hide the post content of titles that do not have that same id as the one clicked. $('.post').filter(function() { return $(this).children('.id').text() != postId; }).children('.postContent').css('display', 'none'); }); }); Here's the headers I get back: Response Headers Date Wed, 27 Aug 2008 12:35:14 GMT Server Apache/2.2.8 (Win32) PHP/5.2.6 X-Powered-By PHP/5.2.6 P3P CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM" Set-Cookie CAKEPHP=deleted; expires=Tue, 28-Aug-2007 12:35:14 GMT; path=/mkb CAKEPHP=mvn519u59tk7kapp9asr4scq91; path=/mkb CAKEPHP=49d5o6b48nf83q8q12lle0pt41; path=/mkb CAKEPHP=mvn519u59tk7kapp9asr4scq91; path=/mkb Content-Length 2 Keep-Alive timeout=5, max=100 Connection Keep-Alive Content-Type text/x-json; charset=UTF-8 Request Headers Host localhost User-Agent Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1 Accept application/json, text/javascript, */* Accept-Language en-us,en;q=0.5 Accept-Encoding gzip,deflate Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive 300 Connection keep-alive X-Requested-With XMLHttpRequest Referer http://localhost/mkb/ Cookie CAKEPHP=49d5o6b48nf83q8q12lle0pt41; CAKEPHP=02sc14jclvued57ghlaprj0j11 Here's the View in the app: <?php echo $javascript->object($post); ?> Any help would be awesome! Thanks Guys. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] 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 -~----------~----~----~----~------~----~------~--~---
