I'm just getting into Dojo and wanted to try a simple AJAX Post like the examples on Dojo's website.
Here is the HTML/JS:
<form method="POST" id="addProjectForm">
<dl>
<dt>Project Name:</dt>
<dd><input dojoType="dijit.form.TextBox" id="projectName"></dd>
<dt>Project Description:</dt>
<dd><textarea dojoType="dijit.form.Textarea" id="projectDescription" style="width: 300px; height: 100px"></textarea></dd>
</dl>
<button dojoType="dijit.form.Button" style="float: right">
Save Project
<script type="dojo/method" event="onClick">
dojo.xhrPost({
url: '/projects/add/',
load: function(data, ioArgs) {
alert(data);
},
error: function(data, ioArgs) {
alert('There was an error');
},
form: 'addProjectForm'
});
</script>
</button>
</form>
and on the backend I have the following:
class ProjectsController extends Zend_Controller_Action
{
public function addAction()
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$projectName = $this->_request->getParam('projectName');
$description = $this->_request->getParam('projectDescription');
print_r($_POST);
}
}
When I click the 'Save Project' button, I get a JS alert box with php output of an empty array so none of the information is getting posted. What am I doing wrong?