Here are the things that I did to get my jquery, json, and ajax
working

1. I included this line in app/config/routes.php
           Router::parseExtensions('rss', 'json', 'xml');  //notice
json over there


2. Then, I created a folder named "json" in my views/post..so my views
folder structure look like this
            views
                 post
                    json
                      message.ctp

In message.ctp, I am using this code to convert PHP array (that came
from controller) to json format

<?php
echo $javascript->object($message);   //$message is the PHP array
?>


3. Now, when I need to data in ajax format, I just add the extension
"json" to my controller-method call. So for the above method
"message", my url look like this

So the url for the ajax call in this case is
              jQuery.ajax("http://localhost/site/post/message.json";,
function(){
                  //add your function here
             });

This will be give you json data as output

The good thing with this approach is that if you remove "json" from
your url, you will get normal output. This assuming you have a file
"message.ctp" in views/post

hope this helps
Regards,


On Feb 16, 3:53 pm, mike <[EMAIL PROTECTED]> wrote:
> How do I send and process ajax request using jquery's .getJson() on
> cakephp. I need to setup dynamic dropdown box? Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to