Hi again!
I was trying, just for learning purpose, to make the form work with
ajax.
The idea is to update a div with different search results from the
database.
This is in my view:

<form onSubmit="return false;">
<input type="radio" name="data[asd]" value="A">A
<input type="radio" name="data[asd]" value="B">B
<input type="radio" name="data[asd]" value="C">C
<?php echo $ajax->submit('Search', array('url' => 'search',
'update'=>'results')); ?>
</form>
<div id="results"><!-- div to update --></div>

And this is the action Search, in the controller:

function search()
        {
                $this->RequestHandler->setAjax($this);
                if (!empty($this->params['data']) && isset($this->data['asd']))
                {
                        switch ($this->data['asd'])
                        {
                                case "A":
                                        $this->set('results', 
$this->Things->findAll());
                                        $this->render('search', 'ajax');
                                        break;
                                case "B":
                                        $this->set('results', 
$this->Things->findAll());
                                        $this->render('search', 'ajax');
                                        break;
                                case "C":
                                        $this->set('results', 
$this->Things->findAll());
                                        $this->render('search', 'ajax');
                                        break;
                        }
                }
        }

(considere the findAll()s just dummies functions for the example..)
I added the helper and linked the libraries to the layout, but don't
work and i do not find any similiar example around the web.
Where is the error?

Thank you!


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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