【发布时间】:2011-06-01 09:10:29
【问题描述】:
我正在使用 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);
}
});
});
});
在我的控制器上,我只是不知道如何从 ajax 检索 POST 数据。
public function saveAction()
{
$data = $this->_request->getPost();
echo $id = $data['id'];
echo $details = $data['details'];
//this wont work;
}
提前致谢。
【问题讨论】:
标签: php jquery ajax zend-framework post