This is something that's so simple, I'm embarrassed to ask. But after
a few dozen Google searches, I'm going to swallow my pride and post my
question here.

I have a simple ajax function in my controller and I want it to return
an error is the request is not successful. For example:

function ajax_update_box($boxId, $aliquotIds){
        if ($this->RequestHandler->isAjax()) { // if the request is AJAX
                if($aliquots = $this->Aliquot->validateMove($aliquotIds, 
$boxId))
{ // make sure a slot is open in the box
                        foreach($aliquots as $aliquot_id => $position ) { // 
validateMove
returns an array
                                if ($this->Aliquot->save($this->data['Aliquot'] 
=! true)) {
                                        Configure::write('debug', 0);
                                        $this->autoRender = false;
                                        exit('There was an error and some of 
the aliquots were not
moved.');
                                }
                        }

                        echo $this->unstored();

                } else { // this is where I want it to return an error.
                        Configure::write('debug', 0);
                        $this->autoRender = false;
                        exit('The move did not work. Check to see if the box is 
full.');

                }
                Configure::write('debug', 0);
                        $this->autoRender = false;
                        exit(0);
        }
}

If the request doesn't pass validation in my model, I want to display
an error message, but I can't seem to get that to work. Everything is
treated as success. What am I missing?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to