无法将数据发布到yii中的测量控制器 index.php 控制器'survey.php' 公共职能行动问题() { //调试目的 回声“; 打印(邮政美元); 出口 } 要做的事
我试图做的是更新CListView,方法是通过POST从dropdownlist获取所选数据,然后由控制器评估,从数据库获取数据并更新CListView无法将数据发布到yii中的测量控制器 index.php 控制器'survey.php' 公共职能行动问题() { //调试目的 回声“; 打印(邮政美元); 出口 } 要做的事,yii,Yii,我试图做的是更新CListView,方法是通过POST从dropdownlist获取所选数据,然后由控制器评估,从数据库获取数据并更新CListView 请帮帮我。我刚开始学Yii。谢谢 您需要为dropdownList添加Id,如下所示 嗨,谢谢你的评论。我尝试了你的建议,就像你提到的那样添加ID,不幸的是我仍然无法启动ajax的执行:(你注册了jquery吗?因为ajax代码依赖于jquery。根据我网站的页面来源:这是注册jquery的方法吗:Yii::app()->clientScrip
请帮帮我。我刚开始学Yii。谢谢 您需要为dropdownList添加Id,如下所示
嗨,谢谢你的评论。我尝试了你的建议,就像你提到的那样添加ID,不幸的是我仍然无法启动ajax的执行:(你注册了jquery吗?因为ajax代码依赖于jquery。根据我网站的页面来源:这是注册jquery的方法吗:Yii::app()->clientScript->registerCoreScript('jquery'))?我已经做了,但没有luckI看到,我还没有在inspect元素上测试控制台部分。控制台显示“成功”,因此ajax功能良好。谢谢。顺便问一下,我如何获得发布数据的值?我假设我发布了类似$_POST[''u designation']=test的内容。我想将数据分配给surveycontroller中的一个变量
<?php
Yii::app()->clientScript->registerScript('items_update',
"$('#dropit').change(function(){
$.ajax({
url: '".Yii::app()->createUrl('survey/questions')."',
data:
{
_designation : test,
},
type: 'POST',
success:function()
{
console.log('success');
},
error:function()
{
console.log('failure');
}
});
return false;
});
");
?>
<div id="surveyupdate">
<?php
echo CHtml::dropDownList('dropit', '',
array(
'Reception'=>'Service Reception',
'SA'=>'ServiceAdvisor','Billing'=>'Billing Staff',
'Parts'=>'Parts Counter','Cashier'=>'Cashier','Cwd'=>'Customer Welfare Desk'),
array('prompt'=>'- select -'));
?>
</div>
<?php
$this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'itemView'=>'_view',
'id'=>'ajaxListView',
));
?>
public function actionQuestions()
{
//debugging purposes
echo "<pre>";
print_r($_POST);
exit;
}
echo CHtml::dropDownList('dropit', '',
array(
'Reception'=>'Service Reception',
'SA'=>'ServiceAdvisor','Billing'=>'Billing Staff',
'Parts'=>'Parts
Counter','Cashier'=>'Cashier','Cwd'=>'Customer Welfare
Desk'),
array('prompt'=>'- select -', 'id'=>'dropit')); // added I'd here