0

我得到了一个内部带有 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 调用。在此操作中,我试图查看请求是否已发布并提醒已发送数据的数据以查看如果它正在工作。

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 的警报。提前致谢...

4

1 回答 1

0

如果您序列化表单并将其作为字符串发送http://api.jquery.com/serialize/可能最简单

于 2013-08-01T15:03:34.353 回答