json response:
$this->getResponse()->setHttpHeader('Content-type', 'application/json');
return $this->renderText(json_encode($todo));
function addNewTodo(checklist_id)
{
var body = jQuery('#todo_body_' + checklist_id).val();
jQuery.ajax({
url: "url_for('checklist/addtodo'); ?>",
type: 'POST',
data: {'id': checklist_id, 'body': body},
dataType: 'json',
beforeSend: function () {
jQuery('#indicator').show();
},
success: function (data) {
jQuery('#indicator').hide();
}
});
return false;
}
component in action:
return $this->renderComponent ('checklist', 'checklist_tr', array( 'todo_id' => $todo->getId(), 'todo_status' => false, 'todo_body' => $todo->getBody(), 'project_id' => $project_id));
function addNewTodo(checklist_id)
{
var body = jQuery('#todo_body_' + checklist_id).val();
jQuery.ajax({
url: "url_for('checklist/addtodo'); ?>",
type: 'POST',
data: {'id': checklist_id, 'body': body},
dataType: 'text',
beforeSend: function () {
jQuery('#indicator').show();
},
success: function (data) {
jQuery('#indicator').hide();
}
});
return false;
}
No comments:
Post a Comment