Also, I'm testing your solution, and it is outputting the element html data but for some reason it's outputting a bunch of other data from the controller, like:
$___dataForView = array() $loadHelpers = true $cached = false $session = SessionHelper SessionHelper::$helpers = array SessionHelper::$__active = true SessionHelper::$valid = false SessionHelper::$error = false SessionHelper::$_userAgent = "082aaf941d57844d51008967f7e4ca5a" and it's a lot of that On Sep 14, 12:07 pm, 8vius <[email protected]> wrote: > I meant $this->element('element', $data); > > On Sep 14, 12:06 pm, 8vius <[email protected]> wrote: > > > > > > > > > And how can I pass an array into the view? I do it in other parts of > > my code just doing $this->render('element', $data) but it's giving me > > an error here > > > On Sep 14, 11:59 am, Thomas Ploch <[email protected]> wrote: > > > > The RequestHandler Component is not doing any requests, it just verifies > > > that the current request indeed is an AJAX request, so you can check in > > > an action and i.e. render an element with an AJAX layout instead of > > > rendering the whole view. You can of course generate the HTML with > > > javascript using the returned JSON object > > > (http://api.jquery.com/jQuery.template). But in my oppinion it is way > > > easier to do the data handling in the action, and just render the > > > element's HTML with $this->render() and use that in the success callback > > > of the jQuery $.post method, appending the rendered HTML into a DOM node. > > > > Am 14.09.2011 17:51, schrieb 8vius: > > > > > hmmm I don't use the request handler to do my ajax requests, I just > > > > echo out the response, would that work ? doing echo $this->render()? > > > > > On Sep 14, 11:36 am, Thomas Ploch<[email protected]> wrote: > > > >> As an addition, check outhttp://book.cakephp.org/view/980/render > > > > >> Am 14.09.2011 17:14, schrieb 8vius: > > > > >>> Can you be a little more explicit? I have my ajax action set up that > > > >>> will return a json encoded array. How can I get the html for the > > > >>> element from my controller? Maybe some example code? I'm a bit of a > > > >>> noob with this in general. Thank you. > > > > >>> On Sep 14, 11:05 am, Thomas Ploch<[email protected]> wrote: > > > >>>> The easiest way would be an AJAX action that renders the element with > > > >>>> the given POST data. The you can just use the rendered HTML and > > > >>>> inject > > > >>>> it into the DOM. > > > > >>>> Kind regards > > > >>>> Thomas > > > > >>>> Am 14.09.2011 16:55, schrieb 8vius: > > > > >>>>> Hey all, got a little problem here. I wanna do something similar to > > > >>>>> what twitter does when you post a new tweet, that it automatically > > > >>>>> adds itself to the stream. I have made an element for this, the > > > >>>>> element receives my model data and sets it up properly but I'm not > > > >>>>> sure how to pass in the data from Jquery (I receive a JSON object). > > > >>>>> So > > > >>>>> what are my options here? How can I accomplish this? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
