Quick answer
I use http://jquery.malsup.com/form/
view:
$('#yourForm').ajaxSubmit( {
success: function(responseText, responseCode) {
var index = responseText.lastIndexOf(':');
var name = responseText.substr(0, index);
var id = responseText.substr(index + 1);
//add new role to Roles in dropdown
}
});
controller:
function admin_add() {
if ($this->Role->save($this->data)) {
if ($this->RequestHandler->isAjax()) {
Configure::write('debug', 0);
$this->autoRender = false;
echo $this->data['Role']['name'].':'.$this-> Role->id;
exit();
} else {
$this->redirect(array('action'=>'index'));
}
}
}
On Dec 7, 8:44 am, SugarCRM Geek <[email protected]> wrote:
> Hello all,
> i have 2 fields in a page. one is a dropdown(Roles) & other is a
> text field(Add New Role).
> The Rolesin the dropdown are coming from the database.
> Now i need to add a New Role. this has to be saved in the DB as i
> click on create. When the page loads again this New Role should be
> shown in the DropDown(Roles) list.
> These 2 fields are part of form, consisting of other stuff too.
>
> Can somebody gimme an idea on this.
> am trying to use AJAX here but its not working.
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