Re: using jquery and json on cakephp

2008-04-16 Thread krusty999

You must set some variable for te output.

Controller:
$this-set('myVariable', $this-User-findAll());
Configure::write('debug',0); //When output Json.

Then in your view app/views/users/data.ctp you can leave empty.

But in your view app/view/users/json/data.ctp you put:
?php
echo $javascript-object($myVariable);   //The same of the controller
?

And then when you enter http://localhost/app/users/data dysplay
nothing, but in

http://localhost/app/users/data.json display the content of
$myVariable in json format.

See ya.

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: using jquery and json on cakephp

2008-04-16 Thread Renan Gonçalves

 [EMAIL PROTECTED]:*

Configure::write('debug',0); //When output Json.


Put this line at json's layout.



[]'s

On Wed, Apr 16, 2008 at 4:41 PM, krusty999 [EMAIL PROTECTED] wrote:


 You must set some variable for te output.

 Controller:
 $this-set('myVariable', $this-User-findAll());
 Configure::write('debug',0); //When output Json.

 Then in your view app/views/users/data.ctp you can leave empty.

 But in your view app/view/users/json/data.ctp you put:
 ?php
 echo $javascript-object($myVariable);   //The same of the controller
 ?

 And then when you enter http://localhost/app/users/data dysplay
 nothing, but in

 http://localhost/app/users/data.json display the content of
 $myVariable in json format.

 See ya.

 



-- 
Renan Gonçalves - Software Engineer
Cell Phone: +55 11 8633 6018
MSN: [EMAIL PROTECTED]
São Paulo - SP/Brazil

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: using jquery and json on cakephp

2008-04-16 Thread Freshow

I checked it again ,but the problem is always, I test it and find that
when call ./post/add.json , the function in post/json/add.ctp  not
work for me, it means ./post/add.json not associate with   ./post/json/
add.ctp , right?

On 4月17日, 上午3时41分, krusty999 [EMAIL PROTECTED] wrote:
 You must set some variable for te output.

 Controller:
 $this-set('myVariable', $this-User-findAll());
 Configure::write('debug',0); //When output Json.

 Then in your view app/views/users/data.ctp you can leave empty.

 But in your view app/view/users/json/data.ctp you put:
 ?php
 echo $javascript-object($myVariable);   //The same of the controller
 ?

 And then when you enterhttp://localhost/app/users/datadysplay
 nothing, but in

 http://localhost/app/users/data.jsondisplay the content of
 $myVariable in json format.

 See ya.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: using jquery and json on cakephp

2008-02-17 Thread mike

Thanks dude:)
I Gonna try this out

On Feb 17, 9:50 am, bingo [EMAIL PROTECTED] wrote:
 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
-~--~~~~--~~--~--~---



using jquery and json on cakephp

2008-02-16 Thread mike

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
-~--~~~~--~~--~--~---



Re: using jquery and json on cakephp

2008-02-16 Thread bingo

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
-~--~~~~--~~--~--~---