我有一个内置jqgrid的表单,当用户点击提交时我想将数据提交给控制器。 这是我的表格
<form method='POST' >
<div class="st-form-line" style="z-index: 680;">
<span class="st-labeltext">Tags da ronda:</span>
<table id="toolbar2"></table>
<div id="ptoolbar2"></div>
<div class="clear" style="z-index: 670;"></div>
</div>
<div class="st-form-line" style="z-index: 680;">
<span class="st-labeltext">Nome da ronda:</span>
<input type="text" name="nomeronda" id="nomeronda">
<div class="clear" style="z-index: 670;"></div>
</div>
<div class="st-form-line" style="z-index: 680;">
<span class="st-labeltext">Tag Inicial:</span>
<select id="tagini" name="tagini">
</select>
<div class="clear" style="z-index: 670;"></div>
</div>
<div class="st-form-line" style="z-index: 680;">
<span class="st-labeltext">Tag Final:</span>
<select id="tagfim" name="tagfim">
</select>
<div class="clear" style="z-index: 670;"></div>
</div>
<div class="st-form-line" style="z-index: 680;">
<span class="st-labeltext">Ordem:</span>
<select id="ordem" name="ordem">
<option value="Sim">Sim</option>
<option value="Não">Não</option>
</select>
<div class="clear" style="z-index: 670;"></div>
</div>
<div class="button-box" style="z-index: 460;">
<input id="button" class="st-button" type="submit" value="Submit" name="button">
<input id="button2" class="st-clear" type="reset" value="Cancel" name="button">
</div>
</form>
现在,当用户点击提交按钮时,它会激活此javascript代码
<script language = "Javascript">
$(document).ready(function() {
$("#button").click(function(){
var param1 = 'first'; //or get value from some DOM element
var param2 = 'second'; //or get value from some DOM element
$.ajax({
url: '/rondas/choosetags/',
type: 'POST',
data: {param1: param1, param2:param2 },
dataType: "json"
});
});
});
</script>
因此,当按下提交按钮时,我对控制器名称rondas进行ajax调用,并且操作名称choosetags .. 在此操作中,我试图查看请求是否发布并提醒发送的数据的数据,以查看它是否正常工作。
if ($this->_request->isPost())
{
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$param1 = $this->_request->getParam('param1');
$param2 = $this->_request->getParam('param2');
echo '<script>alert("'.$param1.'")</script>';
}
问题是我的警报是空白的......警报被触发但$ param1值为空。 我的问题是什么...... 我在这里尝试了不同的解决方案,但我看不到$ param1的警报。 提前谢谢......