I will explain in detail what i am trying to do.
 
Index page has a table with rows of the users entries. I have a "Add New
Entry" which will toggle the add form so the user can add entries directly
from the same page via Ajax. I need 2 things to happen based on the form
being submitted.
1. If the form saves i need to toggle close the form and append the new data
saved to the table of entries.
or
2. if the form does not save simply display the form as is where it is with
the errors hi-lighted.
 
I have no problems with any of the Ajax / appending script i am just stuck
on returning the views. 
Everyone so far says use json in response for true or false so the js will
either update the users entries or do nothing if response comes back false. 
But how do i get the views? How do i update the form with its errors if i
simply return false? 
 
Firebug sure shows my success = false if the form does not save but the end
user has no idea why they are just sitting looking at the form with no
errors marked so i need to respond back with the form html that would
normally show up if it was sent thru normal http request.
 
Same thing goes with the success = true
How do i return the view for the newly added record if it does save?
 
I wish i had a controller to show you but nothing i have works all i have is
just testing true / false responses trying / hoping something / someone will
help
 
if ( $this->RequestHandler->isAjax() ) {
   
   Configure::write ( 'debug', 0 );
        $this->data['Dummy']['id'] = $this->Dummy->generateKey('11');
        $this->data['Dummy']['profile_id'] = $this->Auth->User('id');
      
      $response['data'] = $this->data['Dummy'];
      $response['success'] = true;
        //$response['success'] = false;
        //$response['html'] = ???; how do I get the view
    
    $this->header('Content-Type: application/json');
    echo json_encode($response);

}

My js has:

                dataType: "json",
                success: function(response) {
                        // Response was a success
                        if (response.success === true) {
                                alert('saved ok');
                                //do some stuff
                        } else {
                                alert('did not save');
                        //do some stuff
                        }
                }

Surly someone out there has some idea.

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

Reply via email to