I am trying to populate a zend form by executing a jquery post request on click of a link. I pass the id to the js function so that my action knows which data to populate but the values don’t get populated. The values were being popualated when i was passing the id parameter through URL
JS call
<a href="javascript: edit(id)">
JS function
function edit(id)
{
$.post("url",{'edit':id});
}
inside zend action
if ($this->_request->getParam('edit')) {
$id=$this->_request->getParam('edit');
$table=$Table->findByID($id);
$table->populateForm();
}
Edit
I was able to populate the form and render it on the page by setting the data type of my ajax call to html and passing the populated zend form to the ajax call in the controller
Controller:
echo $form; exit;
Ajax call
success: function(data){ $(#div).html(data)}
Make sure that the data type of your ajax call is html
I was able to populate the form and render it on the page by setting the data type of my ajax call to html and passing the populated zend form to the ajax call in the controller
Controller:
echo $form; exit;Ajax call
success: function(data){ $(#div).html(data)}Make sure that the data type of your ajax call is html