我正在使用zend框架,我想使用Jquery ajax post获取POST数据,以便在不刷新页面的情况下进行保存.
//submit.js
$(function() {
$('#buttonSaveDetails').click(function (){
var details = $('textarea#details').val();
var id = $('#task_id').val();
$.ajax({
type: 'POST',
url: 'http://localhost/myproject/public/module/save',
async: false,
data: 'id=' + id + '&details=' + details,
success: function(responseText) {
//alert(responseText)
console.log(responseText);
}
});
});
});
Run Code Online (Sandbox Code Playgroud)
在我的控制器上,我只是不知道如何从ajax中检索POST数据.
public function saveAction()
{
$data = $this->_request->getPost();
echo $id = $data['id'];
echo $details = $data['details'];
//this wont work;
}
Run Code Online (Sandbox Code Playgroud)
提前致谢.
大家好!我在这里设置子表单元素,它工作正常.
//Setting SubForm element
$subForm = new Zend_Form_SubForm();
$subForm->setName('sampleSubForm');
$subForm->addElement('text', 'test', array(
'value' => 'someValue',
'name' => 'test',
'belongsTo' => 'sampleSubForm',
'size' => '1',
'maxLength' => '1',
'decorators' => array('ViewHelper'),
));
$this->form->addSubForm($subForm, 'sampleSubForm');
Run Code Online (Sandbox Code Playgroud)
我仍然在摆弄并想知道如何在表单提交时访问子表单元素,以设置其值.干杯和快乐的编码!谢谢
array
'subQuantity' =>
array
'quantity_6' => string '23' (length=2)
'quantity_16' => string '23' (length=2)
'quantity_18' => string '23' (length=2)
'update' => string 'Update' (length=6)
Run Code Online (Sandbox Code Playgroud)
美好的一天!我刚从我现有的zend表单创建了一个子表单,并在表单提交时获取这些数据.根据发布的数据(quantity_ elements),我想将值设置为子表单元素.可能吗?提前致谢.欢呼和快乐的编码!