【发布时间】:2014-02-17 13:20:00
【问题描述】:
我在使用 ajax 的 YII 中遇到问题。 我使用this link 作为例子来测试我的项目中的ajax 依赖下拉列表。
表单代码(protected/views/game/_form.php):
<?php
echo $form->dropDownList($model, 'season_id', Season::getSeasonsList(), array(
'ajax' => array(
'type'=>'POST',
CController::createUrl('Game/selectGameStages'),
'update'=>'#Game_season_game_stage'
)
)
);
?>
控制器代码(protected/Controller/GameController.php):
public function actionSelectGameStages()
{
echo CHtml::tag('option', array('value'=>'1'), 'Some output 1', true);
echo CHtml::tag('option', array('value'=>'2'), 'Some output 2', true);
echo CHtml::tag('option', array('value'=>'3'), 'Some output 3', true);
}
Ajax 正在工作,但如果使用调试器创建该代码,则放入我的 Game_season_game_stage 选择是我网站整个页面的 html 代码,如
<select name="Game[season_game_stage] id="Game_season_game_stage">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
...
<div class="container" id="page">...</div>
请帮助理解为什么加载整个页面代码而不是我的 selectGameStages 函数中的代码? Yii 版本是 1.14。 对不起我的英语不好。谢谢。
【问题讨论】:
-
请添加您要更新的代码。