Friday, June 25, 2010

Re: CakePHP Ajax - Getting returned JSON code evaled and into variable

Well, i would say its a cakePHP question, because i am wondering how
to do it within the cakePHP framework.

if i set it up like this:

<div id="post">
</div>
<?php echo $ajax->link(
'View Post',
array( 'controller' => 'posts', 'action' => 'post' ),
array( 'complete' => 'callback()' )
);
?>

And the ajax call only returns a JSON structure, how do i either:
- Get hold of that structure inside the js function
or
- Pass it into the js function as a variable

Forinstance a callback for a Yahoo User Interface request handler
would have a function like this:

success: function(oResponse){...}

And then you fetch the returned json data out of that variable.

Is the callback function specified in the cakePHP called with any
parameters?

On 24 Jun, 20:29, Mike <mfrie...@gmail.com> wrote:
> Just this exact thing this week.... There's a good example here:http://api.jquery.com/jQuery.getJSON/... if your not using jquery you
> can use eval() just the same.
>
> On Jun 24, 9:56 am, Joakim <ban...@gmail.com> wrote:
>
> > Hello,
>
> > I have a ajax link that returns a json datastructure(writes out the
> > json datastructure in the view) and i want to get this evaled and
> > placed into a js datastructure that i can use. How do i manage this?
>
> > All suggestions are really helpful!
>
> > Best regards

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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: