Does anyone know how to return a JSON object from an ajax request to return
the view and a success status? I see all these tutorials to retrn data but
no html. Everything is layout = false, autoRender = false. I can return the
view in normal html but I need to get a status = true or false to the js to
tell it what to do next depending on the status. I need to update 1 of 2
possible divs with the response and that's why I need the success to tell
the js if success update this div if no success then do something different.
I need to return a view along with my success or fail status. Not just an
error message as I have found in my json / cakephp searching.
so in the controller
$this->layout = 'ajax';
if(this->Model->save())
{
//return success = true and success view
$respounse = array('status' => true, 'html' => ???
} else {
//return false
$respounse = array('status' => false);
}
$this->header('Content-Type: application/json');
echo json_encode($response);
Ideas?
Thanks
Dave
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 [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